Comment 2 for bug 529998

Revision history for this message
James Westby (james-w) wrote :

Oh, interesting addendum, this is actually difficult to spot, as the above is
usually written as

  len(lp.me.getBranches())

where __len__ on a Collection is defined as

  def __len__(self):
     try:
        return int(self.total_size)
     except AttributeError:
        raise TypeError('collection size is not available')

presumably trying to catch the case where .total_size isn't an attribute provided
in the response.

When you access .total_size as above then you get

  AttributeError: 'NoneType' object has no attribute 'response'

so it is actually caught by the except block, and you don't notice that it is apparently
a code problem, rather than a limitation of the response.

Therefore I'm not sure that this has ever worked, but we just not have noticed for
this reason.

Thanks,

James