summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-12 20:20:08 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-12 20:20:08 (GMT)
commit611546005ba27bdaf81eb14f625fde0a362ba261 (patch)
tree74568941a837c733190a6500ce96be7361e3dcb8 /Lib
parent547607c4bf97ece7ad5cc50f103cbf651560ac86 (diff)
downloadcpython-611546005ba27bdaf81eb14f625fde0a362ba261.zip
cpython-611546005ba27bdaf81eb14f625fde0a362ba261.tar.gz
cpython-611546005ba27bdaf81eb14f625fde0a362ba261.tar.bz2
Make sure that *any* object whose id() is used as a memo key is kept
alive in the memo. This fixes SF bug 592567.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/copy.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 7d06042..e2474fe 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -185,6 +185,7 @@ def deepcopy(x, memo = None):
else:
y = copierfunction(x, memo)
memo[d] = y
+ _keep_alive(x, memo) # Make sure x lives at least as long as d
return y
_deepcopy_dispatch = d = {}
@@ -269,7 +270,6 @@ def _deepcopy_inst(x, memo):
return x.__deepcopy__(memo)
if hasattr(x, '__getinitargs__'):
args = x.__getinitargs__()
- _keep_alive(args, memo)
args = deepcopy(args, memo)
y = apply(x.__class__, args)
else:
@@ -278,7 +278,6 @@ def _deepcopy_inst(x, memo):
memo[id(x)] = y
if hasattr(x, '__getstate__'):
state = x.__getstate__()
- _keep_alive(state, memo)
else:
state = x.__dict__
state = deepcopy(state, memo)