mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Deleting cyclic object comparison.
SF patch 825639 http://mail.python.org/pipermail/python-dev/2003-October/039445.html
This commit is contained in:
parent
0e4f76405d
commit
2b3eb4062c
9 changed files with 109 additions and 275 deletions
|
|
@ -272,10 +272,10 @@ class TestCopy(unittest.TestCase):
|
|||
x = []
|
||||
x.append(x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y[0] is not x[0])
|
||||
self.assert_(y is y[0])
|
||||
self.assert_(y[0] is y)
|
||||
self.assertEqual(len(y), 1)
|
||||
|
||||
def test_deepcopy_tuple(self):
|
||||
x = ([1, 2], 3)
|
||||
|
|
@ -288,7 +288,7 @@ class TestCopy(unittest.TestCase):
|
|||
x = ([],)
|
||||
x[0].append(x)
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y[0] is not x[0])
|
||||
self.assert_(y[0][0] is y)
|
||||
|
|
@ -304,10 +304,10 @@ class TestCopy(unittest.TestCase):
|
|||
x = {}
|
||||
x['foo'] = x
|
||||
y = copy.deepcopy(x)
|
||||
self.assertEqual(y, x)
|
||||
self.assertRaises(RuntimeError, cmp, y, x)
|
||||
self.assert_(y is not x)
|
||||
self.assert_(y['foo'] is y)
|
||||
self.assertEqual(y, {'foo': y})
|
||||
self.assertEqual(len(y), 1)
|
||||
|
||||
def test_deepcopy_keepalive(self):
|
||||
memo = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue