[Python-checkins] CVS: python/dist/src/Lib/test test_mutants.py,1.5,1.6
Tim Peters
tim_one@users.sourceforge.net
Sat, 02 Jun 2001 21:54:34 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv9638/python/dist/src/Lib/test
Modified Files:
test_mutants.py
Log Message:
lookdict: stop more insane core-dump mutating comparison cases. Should
be possible to provoke unbounded recursion now, but leaving that to someone
else to provoke and repair.
Bugfix candidate -- although this is getting harder to backstitch, and the
cases it's protecting against are mondo contrived.
Index: test_mutants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mutants.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** test_mutants.py 2001/06/02 08:18:58 1.5
--- test_mutants.py 2001/06/03 04:54:32 1.6
***************
*** 216,217 ****
--- 216,285 ----
os.unlink(TESTFN)
del f, dict
+
+
+ ##########################################################################
+ # And another core-dumper from Michael Hudson.
+
+ dict = {}
+
+ # let's force dict to malloc its table
+ for i in range(1, 10):
+ dict[i] = i
+
+ class Machiavelli2:
+ def __eq__(self, other):
+ dict.clear()
+ return 1
+
+ def __hash__(self):
+ return 0
+
+ dict[Machiavelli2()] = Machiavelli2()
+
+ try:
+ dict[Machiavelli2()]
+ except KeyError:
+ pass
+
+ del dict
+
+ ##########################################################################
+ # And another core-dumper from Michael Hudson.
+
+ dict = {}
+
+ # let's force dict to malloc its table
+ for i in range(1, 10):
+ dict[i] = i
+
+ class Machiavelli3:
+ def __init__(self, id):
+ self.id = id
+
+ def __eq__(self, other):
+ if self.id == other.id:
+ dict.clear()
+ return 1
+ else:
+ return 0
+
+ def __repr__(self):
+ return "%s(%s)"%(self.__class__.__name__, self.id)
+
+ def __hash__(self):
+ return 0
+
+ dict[Machiavelli3(1)] = Machiavelli3(0)
+ dict[Machiavelli3(2)] = Machiavelli3(0)
+
+ f = open(TESTFN, "w")
+ try:
+ try:
+ print >> f, dict[Machiavelli3(2)]
+ except KeyError:
+ pass
+ finally:
+ f.close()
+ os.unlink(TESTFN)
+
+ del dict