]> granicus.if.org Git - python/commitdiff
Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 4 Feb 2013 10:57:16 +0000 (12:57 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 4 Feb 2013 10:57:16 +0000 (12:57 +0200)
parses nested mutating sequence.

1  2 
Lib/test/test_functools.py
Lib/test/test_resource.py
Misc/NEWS

index 828673c65a3a15e0e5a94af6ed0a808fa3b2c884,b3803da4a3f5f63c90b993842d1ecdc5aa8baaff..30d7fb6b0c2b70259202a7ffb9764194f05f163f
@@@ -193,30 -179,42 +193,48 @@@ class TestPartial(object)
          f_copy = pickle.loads(pickle.dumps(f))
          self.assertEqual(signature(f), signature(f_copy))
  
-     pass
 +class TestPartialC(BaseTestC, TestPartial):
 -        f = self.thetype(object)
++
+     # Issue 6083: Reference counting bug
+     def test_setstate_refcount(self):
+         class BadSequence:
+             def __len__(self):
+                 return 4
+             def __getitem__(self, key):
+                 if key == 0:
+                     return max
+                 elif key == 1:
+                     return tuple(range(1000000))
+                 elif key in (2, 3):
+                     return {}
+                 raise IndexError
++        f = self.partial(object)
+         self.assertRaisesRegex(SystemError,
+                 "new style getargs format but argument is not a tuple",
+                 f.__setstate__, BadSequence())
  
 -class PartialSubclass(functools.partial):
 -    pass
 +class TestPartialPy(BaseTestPy, TestPartial):
 +
 +    def test_pickle(self):
 +        raise unittest.SkipTest("Python implementation of partial isn't picklable")
 +
 +    def test_repr(self):
 +        raise unittest.SkipTest("Python implementation of partial uses own repr")
  
- class TestPartialCSubclass(BaseTestC, TestPartial):
 -class TestPartialSubclass(TestPartial):
++class TestPartialCSubclass(TestPartialC):
  
 -    thetype = PartialSubclass
 +    class PartialSubclass(c_functools.partial):
 +        pass
  
 -class TestPythonPartial(TestPartial):
 +    partial = staticmethod(PartialSubclass)
  
 -    thetype = PythonPartial
 +class TestPartialPySubclass(TestPartialPy):
  
 -    # the python version hasn't a nice repr
 -    def test_repr(self): pass
 +    class PartialSubclass(c_functools.partial):
 +        pass
  
 -    # the python version isn't picklable
 -    def test_pickle(self): pass
 -    def test_setstate_refcount(self): pass
 +    partial = staticmethod(PartialSubclass)
  
  class TestUpdateWrapper(unittest.TestCase):
  
Simple merge
diff --cc Misc/NEWS
Simple merge