summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-28 21:33:22 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-28 21:33:22 (GMT)
commit1e91c1444a9c8b8b58310cffbe4252698527a31e (patch)
tree72ad8cf8fed363835c3f975cdbfacb519a207d37 /Lib
parent1baeba6839a91fed172a003b251de58939a9dca5 (diff)
downloadcpython-1e91c1444a9c8b8b58310cffbe4252698527a31e.zip
cpython-1e91c1444a9c8b8b58310cffbe4252698527a31e.tar.gz
cpython-1e91c1444a9c8b8b58310cffbe4252698527a31e.tar.bz2
Fix for SF bug ##497426: can't deepcopy recursive new objects
deepcopy(), _reconstruct(): pass the memo to the other function, so that recursive data structures built out of new-style objects may be deeply copied correctly. 2.2.1 bugfix!
Diffstat (limited to 'Lib')
-rw-r--r--Lib/copy.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 14eff05..86fc978 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -172,7 +172,7 @@ def deepcopy(x, memo = None):
raise error, \
"un-deep-copyable object of type %s" % type(x)
else:
- y = _reconstruct(x, reductor(), 1)
+ y = _reconstruct(x, reductor(), 1, memo)
else:
y = copier(memo)
else:
@@ -279,10 +279,12 @@ def _deepcopy_inst(x, memo):
return y
d[types.InstanceType] = _deepcopy_inst
-def _reconstruct(x, info, deep):
+def _reconstruct(x, info, deep, memo=None):
if isinstance(info, str):
return x
assert isinstance(info, tuple)
+ if memo is None:
+ memo = {}
n = len(info)
assert n in (2, 3)
callable, args = info[:2]
@@ -291,11 +293,11 @@ def _reconstruct(x, info, deep):
else:
state = {}
if deep:
- args = deepcopy(args)
+ args = deepcopy(args, memo)
y = callable(*args)
if state:
if deep:
- state = deepcopy(state)
+ state = deepcopy(state, memo)
y.__dict__.update(state)
return y