[issue1393] function comparing lacks NotImplemented error
Guido van Rossum
report at bugs.python.org
Fri Nov 9 01:23:01 CET 2007
Guido van Rossum added the comment:
It's still odd though. Why does object() == Anything() pass control to
the right hand side, while (lambda: None) == Anything() doesn't?
There's no definition of equality in PyFunction_Type, so it would seem
to fall back on the definition in PyBaseObject_Type, which I would
expect to return False from the code in object_richcompare()...
[...gdb...]
OK, here's the solution of the mystery. do_richcompare() ends up taking
the swapped code path for object() == Anything(), but not for function
objects. This is because Anything() is a subclass of object, but not of
<function>.
Perhaps the solution is to change object_richcompare() to return
NotImplemented instead of returning False? Or perhaps even remove
object_richcompare() altogether, since it doesn't do anything that
do_richcompare() doesn't know how to do...
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1393>
__________________________________
More information about the Python-bugs-list
mailing list