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):