Some wording suggestions:

s/comm_rank/rank/

Perhaps change the last sentence to something like:

"An exception is raised if the length of this list is not the same as the communicator's size."