summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-04 10:45:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-04 10:45:46 (GMT)
commita07a8b4f18c9f3a6eb14080dcbef4dc23a2d3f3b (patch)
tree90dbe40b508a126e0ee9f20b2297995bd5cd67ff /Lib/test/test_functools.py
parentf727c31133822b3e39f851fcca9d3239f389c054 (diff)
downloadcpython-a07a8b4f18c9f3a6eb14080dcbef4dc23a2d3f3b.zip
cpython-a07a8b4f18c9f3a6eb14080dcbef4dc23a2d3f3b.tar.gz
cpython-a07a8b4f18c9f3a6eb14080dcbef4dc23a2d3f3b.tar.bz2
Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple
parses nested mutating sequence.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 562cb82..e9c243b 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -151,6 +151,23 @@ class TestPartial(unittest.TestCase):
f_copy = pickle.loads(pickle.dumps(f))
self.assertEqual(signature(f), signature(f_copy))
+ # 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)
+ self.assertRaises(SystemError, f.__setstate__, BadSequence())
+
class PartialSubclass(functools.partial):
pass
@@ -164,6 +181,7 @@ class TestPythonPartial(TestPartial):
# the python version isn't picklable
def test_pickle(self): pass
+ def test_setstate_refcount(self): pass
class TestUpdateWrapper(unittest.TestCase):