[issue5964] WeakSet cmp methods

Robert Schuppenies report at bugs.python.org
Fri May 15 17:37:20 CEST 2009


Robert Schuppenies <robert.schuppenies at gmail.com> added the comment:

Maybe because I take the doc too specfic. It says "A rich comparison
method may return the singleton NotImplemented if it does not implement
the operation for a given pair of arguments."

I see the type check of the 'other' object as an operation towards the
equal comparison, since it validates wether 'self' and 'other' can be
equal at all. If they are of a different type, then they cannot be
equal, thus the anwser to "Are 'self' and 'other' equal?" should be
False. This again, would mean an equal operation is implemented and
returning NotImplemented is not the right anwser.

But going through similar code snippets shows otherwise, so my
understanding must be lacking something. Therefore here is patch which
returns NotImplemented.

----------
Added file: http://bugs.python.org/file13989/_weakrefset-notimplemented.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5964>
_______________________________________


More information about the Python-bugs-list mailing list