[issue2235] __eq__ / __hash__ check doesn't take inheritance into account

Nick Coghlan report at bugs.python.org
Wed Jul 2 16:42:19 CEST 2008


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Suggestion from GvR (one I like): instead of re-using Py_None, add a new
C function that is stored in the tp_hash slot as a sentinel instead of
the Py_None value used in the posted version of the patch. This will
avoid breaking code that just checks for NULL before calling the tp_hash
slot directly, while still allowing typeobject.c to detect that the
object isn't actually hashable despite the presence of a non-NULL value
in the tp_hash slot.

(I'll keep the None at the Python level though, since that matches the
Py3k behaviour and plays nicely with collections.Hashable)

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


More information about the Python-bugs-list mailing list