bool(Lea) doesn't raise an exception
Issue #34
closed
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 (8)
-
reporter -
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__
andLea.__rdiv__
. -
repo owner - changed status to open
-
repo owner -
assigned issue to
-
assigned issue to
-
repo owner Add Lea.bool method for Python 3 (references
#34)→ <<cset 93d008ec3c87>>
-
repo owner - changed status to resolved
Done in Lea 2.2.0-beta.9
-
repo owner - changed status to closed
-
repo owner Add Lea.bool method for Python 3 (references
#34)→ <<cset 536a552ad6af>>
- Log in to comment
This is because the
__nonzero__
method is named__bool__
in Python 3. Adding__bool__ = __nonzero__
fixes this.