Changes between Version 1 and Version 4 of Ticket #26083
- Timestamp:
- Jul 6, 2016, 12:13:15 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #26083
- Property Triage Stage Unreviewed → Accepted
- Property Summary __eq__, __hash__ and Python 3 → Python 2 deprecation warnings for classes that define __eq__() but not __hash__()
-
Ticket #26083 – Description
v1 v4 1 I ran `python -Werror runtests.py` for DRF, and noticed quite a lot of warnings about `__eq__` and `__hash__`, and then checked Django's repository. 1 Many classes within Django define the `__eq__` method, which in Python 3 will have disruptive implications for inheritance of `__hash__`. See the [https://docs.python.org/3.4/reference/datamodel.html#object.__hash__ Python 3 documentation for `__hash__`]: 2 2 3 `DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x` 3 If a class does not define an __eq__() method it should not define a __hash__() operation either; if it defines __eq__() but not __hash__(), its instances will not be usable as items in hashable collections. […] 4 5 and continues on to describe in detail the implications of defining `__eq__` and/or `__hash__`, and exactly why one would implement one and/or the other on a class. 6 7 The warning emitted by `python2 -3` for this is: 8 9 DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x