python/dist/src/Lib/test test_builtin.py, 1.34, 1.35

Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9824/lib/test Modified Files: test_builtin.py Log Message: Checkin Tim's fix to an error discussed on python-dev. Also, add a testcase. Formerly, the list_extend() code used several local variables to remember its state across iterations. Since an iteration could call arbitrary Python code, it was possible for the list state to be changed. The new code uses dynamic structure references instead of C locals. So, they are always up-to-date. After list_resize() is called, its size has been updated but the new cells are filled with NULLs. These needed to be filled before arbitrary iteration code was called; otherwise, that code could attempt to modify a list that was in a semi-invalid state. The solution was to change the ob->size field back to a value reflecting the actual number of valid cells. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- test_builtin.py 7 Aug 2004 19:20:05 -0000 1.34 +++ test_builtin.py 26 Sep 2004 19:24:19 -0000 1.35 @@ -712,6 +712,11 @@ # http://sources.redhat.com/ml/newlib/2002/msg00369.html self.assertRaises(MemoryError, list, xrange(sys.maxint // 2)) + # This code used to segfault in Py2.4a3 + x = [] + x.extend(-y for y in x) + self.assertEqual(x, []) + def test_long(self): self.assertEqual(long(314), 314L) self.assertEqual(long(3.14), 3L)
participants (1)
-
rhettingerīŧ users.sourceforge.net