summaryrefslogtreecommitdiffstats
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:52:26 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:52:26 (GMT)
commitdca9de97b4256c8aad8a423d6f1d889d2bae9b3d (patch)
treea3bad4b9e4b5fe279288df47c64f569ab991e2c4 /Lib/copy.py
parentdd806cef090256f88dfe0ad88bdcba200be4cb78 (diff)
downloadcpython-dca9de97b4256c8aad8a423d6f1d889d2bae9b3d.zip
cpython-dca9de97b4256c8aad8a423d6f1d889d2bae9b3d.tar.gz
cpython-dca9de97b4256c8aad8a423d6f1d889d2bae9b3d.tar.bz2
Merged revisions 84495-84496 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84495 | antoine.pitrou | 2010-09-04 19:40:21 +0200 (sam., 04 sept. 2010) | 4 lines Issue #1100562: Fix deep-copying of objects derived from the list and dict types. Patch by Michele Orrù and Björn Lindqvist. ........ r84496 | antoine.pitrou | 2010-09-04 19:40:51 +0200 (sam., 04 sept. 2010) | 3 lines Fix Björn's name in ACKS. ........
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index bbbd5b3..c227a2e 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -328,17 +328,7 @@ def _reconstruct(x, info, deep, memo=None):
args = deepcopy(args, memo)
y = callable(*args)
memo[id(x)] = y
- if listiter is not None:
- for item in listiter:
- if deep:
- item = deepcopy(item, memo)
- y.append(item)
- if dictiter is not None:
- for key, value in dictiter:
- if deep:
- key = deepcopy(key, memo)
- value = deepcopy(value, memo)
- y[key] = value
+
if state:
if deep:
state = deepcopy(state, memo)
@@ -354,6 +344,18 @@ def _reconstruct(x, info, deep, memo=None):
if slotstate is not None:
for key, value in slotstate.iteritems():
setattr(y, key, value)
+
+ if listiter is not None:
+ for item in listiter:
+ if deep:
+ item = deepcopy(item, memo)
+ y.append(item)
+ if dictiter is not None:
+ for key, value in dictiter:
+ if deep:
+ key = deepcopy(key, memo)
+ value = deepcopy(value, memo)
+ y[key] = value
return y
del d
@@ -416,6 +418,16 @@ def _test():
print map(repr.repr, l1)
print map(repr.repr, l2)
print map(repr.repr, l3)
+ class odict(dict):
+ def __init__(self, d = {}):
+ self.a = 99
+ dict.__init__(self, d)
+ def __setitem__(self, k, i):
+ dict.__setitem__(self, k, i)
+ self.a
+ o = odict({"A" : "B"})
+ x = deepcopy(o)
+ print(o, x)
if __name__ == '__main__':
_test()