Daniel Jakots <[email protected]> writes:

> Hi,
>
> I wanted to add a py3 flavor to net/py-ripe.atlas.tools which depends
> on net/py-ripe.atlas.sagan wich itself depends on py-IP, hence this
> diff.
>
> I only tried py-ripe.atlas.tools so please test it, thanks.

As I said the tests fail with python3.4 on i386:

  https://pbot.rmdir.de/3I3_OxgyBOqIqgR3KtBWLw

The reason is that IPy.IP() defines a __nonzero__() method, but python
3 tries to use __bool__() instead, falling back to __len__().  Adding
a __bool__ method fixes the regress tests, but the len() method
remains broken on 32 bits, using python2.7 or python3.4.

--- IPy.py.orig Mon Dec 14 13:28:56 2015
+++ IPy.py      Mon Dec 14 13:44:43 2015
@@ -558,6 +558,13 @@ class IPint(object):
         """
         return True
 
+    def __bool__(self):
+        """All IPy objects should evaluate to true in boolean context.
+        Ordinarily they do, but if handling a default route expressed as
+        0.0.0.0/0, the __len__() of the object becomes 0, which is used
+        as the boolean value of the object.
+        """
+        return True
 
     def __len__(self):
         """


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to