bool(Lea) doesn't raise an exception

Issue #34 closed
Paul Moore
created an issue

From the code in lea.py it looks like bool(lea_value) is intended to raise an exception, but it doesn't seem to do so:

>>> from lea import Lea
>>> bool(Lea.fromVals(True))
True
>>> bool(Lea.fromVals(False))
True

Comments (7)

  1. Pierre Denis repo owner

    Well spotted! You're perfectly right. I'll do the fix that you suggest, although in a converse way because I prefer the cleaner Python 3 to be the baseline:

        def __bool__(self):   ## <--- renamed!
            raise ...
        # Python 2 compatibility
        __nonzero__ = __bool__
    

    You can see this pattern for Lea.__div__ and Lea.__rdiv__.

  2. Log in to comment