From: Serhiy Storchaka Date: Mon, 4 Feb 2013 10:57:16 +0000 (+0200) Subject: Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple X-Git-Tag: v3.4.0a1~1451 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6a53404b782c74bd9f7817ddb97f33642146d0c;p=python Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple parses nested mutating sequence. --- b6a53404b782c74bd9f7817ddb97f33642146d0c diff --cc Lib/test/test_functools.py index 828673c65a,b3803da4a3..30d7fb6b0c --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@@ -193,30 -179,42 +193,48 @@@ class TestPartial(object) f_copy = pickle.loads(pickle.dumps(f)) self.assertEqual(signature(f), signature(f_copy)) +class TestPartialC(BaseTestC, TestPartial): - pass ++ + # 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.thetype(object) ++ 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):