summaryrefslogtreecommitdiff
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-06 18:18:23 +0000
committerGuido van Rossum <guido@python.org>2003-02-06 18:18:23 +0000
commite311453b3124708ab886685890272c5276b118d0 (patch)
tree6be67b6bf5ea186b9088ba07171d7b37ed10bdcc /Lib/copy.py
parentb183f6e8a5e8e61c19780c98fcfd0b49adcdf3c6 (diff)
downloadcpython-e311453b3124708ab886685890272c5276b118d0.tar.gz
Support __reduce__ returning a 4-tuple or 5-tuple.
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 59886cbe8f..1845284951 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -297,15 +297,34 @@ def _reconstruct(x, info, deep, memo=None):
if memo is None:
memo = {}
n = len(info)
- assert n in (2, 3)
+ assert n in (2, 3, 4, 5)
callable, args = info[:2]
if n > 2:
state = info[2]
else:
state = {}
+ if n > 3:
+ listiter = info[3]
+ else:
+ listiter = None
+ if n > 4:
+ dictiter = info[4]
+ else:
+ dictiter = None
if deep:
args = deepcopy(args, memo)
y = callable(*args)
+ 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)