[Python-checkins] python/dist/src/Lib copy.py,1.30,1.31

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 06 Feb 2003 10:18:26 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv827

Modified Files:
	copy.py 
Log Message:
Support __reduce__ returning a 4-tuple or 5-tuple.


Index: copy.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** copy.py	16 Jan 2003 10:40:00 -0000	1.30
--- copy.py	6 Feb 2003 18:18:23 -0000	1.31
***************
*** 298,302 ****
          memo = {}
      n = len(info)
!     assert n in (2, 3)
      callable, args = info[:2]
      if n > 2:
--- 298,302 ----
          memo = {}
      n = len(info)
!     assert n in (2, 3, 4, 5)
      callable, args = info[:2]
      if n > 2:
***************
*** 304,310 ****
--- 304,329 ----
      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: