summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-12 05:18:58 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-12 05:18:58 (GMT)
commitaf90b3e610212a4994962246875e5bfc5574dff6 (patch)
tree241056a3295c441dc7ef56d2cd690af5f1287281 /Lib/test/test_descr.py
parent7a29bd58614da9fc478d7167ba918d92c2dcca7e (diff)
downloadcpython-af90b3e610212a4994962246875e5bfc5574dff6.zip
cpython-af90b3e610212a4994962246875e5bfc5574dff6.tar.gz
cpython-af90b3e610212a4994962246875e5bfc5574dff6.tar.bz2
str_subtype_new, unicode_subtype_new:
+ These were leaving the hash fields at 0, which all string and unicode routines believe is a legitimate hash code. As a result, hash() applied to str and unicode subclass instances always returned 0, which in turn confused dict operations, etc. + Changed local names "new"; no point to antagonizing C++ compilers.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b791037..8d9e81e 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1366,6 +1366,7 @@ def inherits():
a = hexint(12345)
verify(int(a) == 12345)
verify(int(a).__class__ is int)
+ verify(hash(a) == hash(12345))
verify((+a).__class__ is int)
verify((a >> 0).__class__ is int)
verify((a << 0).__class__ is int)
@@ -1388,6 +1389,7 @@ def inherits():
verify(str(5 + octlong(3000)) == "05675")
a = octlong(12345)
verify(long(a) == 12345L)
+ verify(hash(a) == hash(12345L))
verify(long(a).__class__ is long)
verify((+a).__class__ is long)
verify((-a).__class__ is long)
@@ -1425,6 +1427,7 @@ def inherits():
a = precfloat(12345)
verify(float(a) == 12345.0)
verify(float(a).__class__ is float)
+ verify(hash(a) == hash(12345.0))
verify((+a).__class__ is float)
class madtuple(tuple):
@@ -1447,6 +1450,7 @@ def inherits():
a = madtuple((1,2,3,4,5))
verify(tuple(a) == (1,2,3,4,5))
verify(tuple(a).__class__ is tuple)
+ verify(hash(a) == hash((1,2,3,4,5)))
verify(a[:].__class__ is tuple)
verify((a * 1).__class__ is tuple)
verify((a * 0).__class__ is tuple)
@@ -1485,6 +1489,9 @@ def inherits():
s = madstring(base)
verify(str(s) == base)
verify(str(s).__class__ is str)
+ verify(hash(s) == hash(base))
+ verify({s: 1}[base] == 1)
+ verify({base: 1}[s] == 1)
verify((s + "").__class__ is str)
verify(s + "" == base)
verify(("" + s).__class__ is str)
@@ -1538,6 +1545,9 @@ def inherits():
u = madunicode(base)
verify(unicode(u) == base)
verify(unicode(u).__class__ is unicode)
+ verify(hash(u) == hash(base))
+ verify({u: 1}[base] == 1)
+ verify({base: 1}[u] == 1)
verify(u.strip().__class__ is unicode)
verify(u.strip() == base)
verify(u.lstrip().__class__ is unicode)