﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19634	Broken __hash__ methods	Anssi Kääriäinen	Aymeric Augustin	"We have some classes which defined `__eq__` but not `__hash__` before the py3 support. Python 3 doesn't allow these objects to be used in dicts, so the fix was to introduce:
{{{
__hash__ = object.__hash__
}}}

However, this is doing the wrong thing. The Python docs say that the only requirement is that objects which compare equal have the same hash value. However, if we define `__eq__` so that it makes object with different id() values equal, then object.`__hash__` is failing this requirement.

This isn't a regression - we have done the same thing implicitly in python 2 for ages. However, py3 introduced the requirement of defining `__hash__` exactly to avoid this situation, so we should consider fixing the `__hash__` functions somehow.

I am not sure what the implications of abusing `object.__hash__` are.

The problematic cases seem to be:
{{{
> git grep '__hash__ = obj'
django/db/backends/__init__.py:    __hash__ = object.__hash__
django/db/models/fields/__init__.py:    __hash__ = object.__hash__
django/dispatch/saferef.py:    __hash__ = object.__hash__
django/test/html.py:    __hash__ = object.__hash__
django/utils/functional.py:        __hash__ = object.__hash__
}}}"	Bug	closed	Python 3	dev	Normal	fixed	sprint2013		Accepted	0	0	0	0	0	0
