diff options
author | Raymond Hettinger <python@rcn.com> | 2004-09-26 19:24:20 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-09-26 19:24:20 (GMT) |
commit | aa241e014979612e2c8851bf9b12c16bcc07b161 (patch) | |
tree | cc33f2bd537e8d23dc24cf479829627280a25b36 /Lib/test/test_builtin.py | |
parent | 55593c3ef530ea01b1cfb1f7c81ee34fd994d0ef (diff) | |
download | cpython-aa241e014979612e2c8851bf9b12c16bcc07b161.zip cpython-aa241e014979612e2c8851bf9b12c16bcc07b161.tar.gz cpython-aa241e014979612e2c8851bf9b12c16bcc07b161.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 8e3a925..9f90925 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -712,6 +712,11 @@ class BuiltinTest(unittest.TestCase): # 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) |