Commit 85233bf7 authored by Guido van Rossum's avatar Guido van Rossum

Fix a bug in the way __getnewargs__ was handled.

parent 694d9b35
......@@ -128,7 +128,7 @@ def _better_reduce(obj):
listitems = iter(obj)
elif isinstance(obj, dict):
dictitems = obj.iteritems()
return __newobj__, (cls, args), state, listitems, dictitems
return __newobj__, (cls,) + args, state, listitems, dictitems
_copy_dispatch = d = {}
......
......@@ -454,6 +454,24 @@ class TestCopy(unittest.TestCase):
self.assert_(x[0] is not y[0])
self.assert_(x.foo is not y.foo)
def test_copy_tuple_subclass(self):
class C(tuple):
pass
x = C([1, 2, 3])
self.assertEqual(tuple(x), (1, 2, 3))
y = copy.copy(x)
self.assertEqual(tuple(y), (1, 2, 3))
def test_deepcopy_tuple_subclass(self):
class C(tuple):
pass
x = C([[1, 2], 3])
self.assertEqual(tuple(x), ([1, 2], 3))
y = copy.deepcopy(x)
self.assertEqual(tuple(y), ([1, 2], 3))
self.assert_(x is not y)
self.assert_(x[0] is not y[0])
def test_main():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestCopy))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment