]> granicus.if.org Git - python/commitdiff
Forward port only Py3k relevant change in r65642 (giving it a Py3k NEWS entry anyway...
authorNick Coghlan <ncoghlan@gmail.com>
Mon, 18 Aug 2008 12:31:52 +0000 (12:31 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Mon, 18 Aug 2008 12:31:52 +0000 (12:31 +0000)
Lib/numbers.py
Misc/NEWS

index c72a23df39fd14ba3b8fc6b8c1a532c2f6dc6753..827c25379ff8cb21f06310b9f956cd3451c1be09 100644 (file)
@@ -15,6 +15,8 @@ class Number(metaclass=ABCMeta):
     If you just want to check if an argument x is a number, without
     caring what kind, use isinstance(x, Number).
     """
+    # Concrete numeric types must provide their own hash implementation
+    __hash__ = None
 
 
 ## Notes on Decimal
index afbe9890b6b3cfc8ed3fd207144bb9e4ae0fd9c3..78cae2908136c9e7d6f76d25b55d535641f698bd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,12 @@ Core and Builtins
 Library
 -------
 
+- Issue #2235: numbers.Number now blocks inheritance of the default id()
+  based hash because that hash mechanism is not correct for numeric types.
+  All concrete numeric types that inherit from Number (rather than just
+  registering with it) must explicitly provide a hash implementation in
+  order for their instances to be hashable.
+
 - Issue #2676: in the email package, content-type parsing was hanging on
   pathological input because of quadratic or exponential behaviour of a
   regular expression.