changeset 382:36429b2aa628

copy.py should be compatible with Python 2.3 now imported from: moin--main--1.5--patch-386
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 17 Jan 2006 07:45:18 +0000
parents f0ecf4656a58
children 1c86e97448fa
files ChangeLog MoinMoin/support/copy.py
diffstat 2 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jan 16 19:28:09 2006 +0000
+++ b/ChangeLog	Tue Jan 17 07:45:18 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-01-17 08:45:18 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-386
+
+    Summary:
+      copy.py should be compatible with Python 2.3 now
+    Revision:
+      moin--main--1.5--patch-386
+
+    copy.py should be compatible with Python 2.3 now
+    
+
+    modified files:
+     ChangeLog MoinMoin/support/copy.py
+
+
 2006-01-16 20:28:09 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-385
 
     Summary:
--- a/MoinMoin/support/copy.py	Mon Jan 16 19:28:09 2006 +0000
+++ b/MoinMoin/support/copy.py	Tue Jan 17 07:45:18 2006 +0000
@@ -1,7 +1,10 @@
-"""This is a copy of python 2.4.2 copy.py as it was broken in:
+"""This is a (modified) copy of python 2.4.2 copy.py as it was broken in:
    Python 2.3.x, x < 5
    Python 2.4.x, x < 1
 
+   Modifications done are minimal, so that same copy.py can work under 2.3
+   and 2.4 python (try: ... except: ... around some set stuff).
+
 Generic (shallow and deep) copying operations.
 
 Interface summary:
@@ -117,9 +120,14 @@
 def _copy_immutable(x):
     return x
 for t in (types.NoneType, int, long, float, bool, str, tuple,
-          frozenset, type, xrange, types.ClassType,
+          type, xrange, types.ClassType,
           types.BuiltinFunctionType):
     d[t] = _copy_immutable
+try:
+    d[frozenset] = _copy_immutable
+except:
+    pass
+    
 for name in ("ComplexType", "UnicodeType", "CodeType"):
     t = getattr(types, name, None)
     if t is not None:
@@ -127,8 +135,12 @@
 
 def _copy_with_constructor(x):
     return type(x)(x)
-for t in (list, dict, set):
+for t in (list, dict):
     d[t] = _copy_with_constructor
+try:
+    d[set] = _copy_with_constructor
+except:
+    pass
 
 def _copy_with_copy_method(x):
     return x.copy()