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

Nick Coghlan report at bugs.python.org
Sun Jun 29 14:25:44 CEST 2008


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

Attached patch allows classes to explicitly block inheritance of
object.__hash__ by setting the tp_hash slot to Py_None or the __hash__
attribute to None.

This is similar to the approach used in Py3k, but allows __hash__ to be
inherited by default, with classes explicitly disabling it as
appropriate. I'd also suggest forward porting this approach to Py3k as
well, and then possibly look at replacing a copied tp_hash slot with
Py_None when the inherited tp_hash is object.tp_hash, but tp_cmp or
tp_richcompare are different.

Added file: http://bugs.python.org/file10773/issue2235_fix_hash_inheritance.diff

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


More information about the Python-bugs-list mailing list