[Python-checkins] CVS: python/dist/src/Lib/test test_operations.py,1.3,1.4

Tim Peters tim_one@users.sourceforge.net
Wed, 23 May 2001 16:34:00 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv1630/python/dist/src/Lib/test

Modified Files:
	test_operations.py 
Log Message:
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.


Index: test_operations.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_operations.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** test_operations.py	2000/10/23 17:22:07	1.3
--- test_operations.py	2001/05/23 23:33:57	1.4
***************
*** 27,28 ****
--- 27,43 ----
  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