[Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.15,
1.15.6.1
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Fri Aug 29 17:13:18 EDT 2003
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv796/Lib/test
Modified Files:
Tag: release23-maint
test_itertools.py
Log Message:
SF bug #793826: using itertools.izip to mutate tuples
Avoid Armin Rigo's dastardly exercise in re-entrancy.
Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.15
retrieving revision 1.15.6.1
diff -C2 -d -r1.15 -r1.15.6.1
*** test_itertools.py 29 Jun 2003 20:36:23 -0000 1.15
--- test_itertools.py 29 Aug 2003 23:13:16 -0000 1.15.6.1
***************
*** 426,429 ****
--- 426,459 ----
self.assertRaises(ZeroDivisionError, list, dropwhile(isOdd, E(s)))
+ class RegressionTests(unittest.TestCase):
+
+ def test_sf_793826(self):
+ # Fix Armin Rigo's successful efforts to wreak havoc
+
+ def mutatingtuple(tuple1, f, tuple2):
+ # this builds a tuple t which is a copy of tuple1,
+ # then calls f(t), then mutates t to be equal to tuple2
+ # (needs len(tuple1) == len(tuple2)).
+ def g(value, first=[1]):
+ if first:
+ del first[:]
+ f(z.next())
+ return value
+ items = list(tuple2)
+ items[1:1] = list(tuple1)
+ gen = imap(g, items)
+ z = izip(*[gen]*len(tuple1))
+ z.next()
+
+ def f(t):
+ global T
+ T = t
+ first[:] = list(T)
+
+ first = []
+ mutatingtuple((1,2,3), f, (4,5,6))
+ second = list(T)
+ self.assertEqual(first, second)
+
libreftest = """ Doctest for examples in the library reference: libitertools.tex
***************
*** 560,564 ****
def test_main(verbose=None):
! test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC)
test_support.run_unittest(*test_classes)
--- 590,595 ----
def test_main(verbose=None):
! test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
! RegressionTests)
test_support.run_unittest(*test_classes)
More information about the Python-checkins
mailing list