seznam / fastrpc

FastRPC library
http://seznam.github.io/frpc
GNU Lesser General Public License v2.1
46 stars 46 forks source link

fastrp.Boolean isn't bool comparable #26

Closed rembish closed 8 years ago

rembish commented 8 years ago

There are few issues with fastrpc.Boolean

from fastrpc import Boolean
Boolean(True) is True  # => False
Boolean(False) is False  # => False
Boolean(True).__nonzero__()  # raises AttributeError
from fastrpc import Boolean
Boolean(True) != None  # 5.x => True
Boolean(True) != None  # 7.x raises TypeError: arg #2 is not a Boolean
rembish commented 8 years ago

BTW ifs work well:

from fastrpc import Boolean
if Boolean(True):
    print("TRUE")
if not Boolean(False):
    print("FALSE")
volca02 commented 8 years ago

Boolean(True) is True

This code, and similar (i.e. operator is) returning false is understandable, since the instances will never be equal (fastrpc.Boolean is not of a python boolean type). Comparison to None and/or other types will be fixed.