Skip to content

Commit 36f4952

Browse files
committed
Forward port only Py3k relevant change in r65642 (giving it a Py3k NEWS entry anyway because of the difference in the changes between the two branches)
1 parent 7d10c2b commit 36f4952

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lib/numbers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class Number(metaclass=ABCMeta):
1515
If you just want to check if an argument x is a number, without
1616
caring what kind, use isinstance(x, Number).
1717
"""
18+
# Concrete numeric types must provide their own hash implementation
19+
__hash__ = None
1820

1921

2022
## Notes on Decimal

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ Core and Builtins
3030
Library
3131
-------
3232

33+
- Issue #2235: numbers.Number now blocks inheritance of the default id()
34+
based hash because that hash mechanism is not correct for numeric types.
35+
All concrete numeric types that inherit from Number (rather than just
36+
registering with it) must explicitly provide a hash implementation in
37+
order for their instances to be hashable.
38+
3339
- Issue #2676: in the email package, content-type parsing was hanging on
3440
pathological input because of quadratic or exponential behaviour of a
3541
regular expression.

0 commit comments

Comments
 (0)