summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_operations.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-05-23 23:33:57 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-05-23 23:33:57 (GMT)
commit0c6010be75cf537e74dfa1584a19dae2247f903b (patch)
treea57165e9c8aa18b9a11c185f3bd018c9dacd65e8 /Lib/test/test_operations.py
parenta5ca7dd71ad0b3d05e884c43aacbc37619af9779 (diff)
downloadcpython-0c6010be75cf537e74dfa1584a19dae2247f903b.zip
cpython-0c6010be75cf537e74dfa1584a19dae2247f903b.tar.gz
cpython-0c6010be75cf537e74dfa1584a19dae2247f903b.tar.bz2
Jack Jansen hit a bug in the new dict code, reported on python-dev.
dictresize() was too aggressive about never ever resizing small dicts. If a small dict is entirely full, it needs to rebuild it despite that it won't actually resize it, in order to purge old dummy entries thus creating at least one virgin slot (lookdict assumes at least one such exists). Also took the opportunity to add some high-level comments to dictresize.
Diffstat (limited to 'Lib/test/test_operations.py')
-rw-r--r--Lib/test/test_operations.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_operations.py b/Lib/test/test_operations.py
index 4c76a8f..3a9a379 100644
--- a/Lib/test/test_operations.py
+++ b/Lib/test/test_operations.py
@@ -26,3 +26,18 @@ x2 = BadDictKey()
d[x1] = 1
d[x2] = 2
print "No exception passed through."
+
+# Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
+# This version got an assert failure in debug build, infinite loop in
+# release build. Unfortunately, provoking this kind of stuff requires
+# a mix of inserts and deletes hitting exactly the right hash codes in
+# exactly the right order, and I can't think of a randomized approach
+# that would be *likely* to hit a failing case in reasonable time.
+
+d = {}
+for i in range(5):
+ d[i] = i
+for i in range(5):
+ del d[i]
+for i in range(5, 9): # i==8 was the problem
+ d[i] = i