autocracy / python-ipy

IPy are a Python class and tools for handling of IPv4 and IPv6 addresses and networks. It is similar to Net::IP Perl module.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There is a 'small' documentation issue in IPy.PY

d1b opened this issue · comments

There is a 'minor' documentation issue in IPy.PY 
  line:569  def __len__(self):

        """Return the length of a subnet.

  Called to implement the built-in function len().
   It breaks with IPv6 Networks. Anybody knows how to fix this."""
   ...
           return int(self.len())

The reason that it breaks with ipv6 is that len() must return an integer. Calling int() before returning the result is not enough. I do not think it would be desirable to alter the current behaviour. Perhaps a note could be added to the documentation about the fact that len(IPy.IP(...) ) for ipv6 ranges may result in an exception being raised and that IPy.IP(..).len() should be used instead.

Alright, looked into this and confirmed that it can't be fixed in code, so documentation it shall be.

http://stackoverflow.com/q/15650878/90322

Fixed via documentation in 71a61cf