summaryrefslogtreecommitdiffstats
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-14 17:41:36 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-14 17:41:36 (GMT)
commit55d2f3997e208a290ee3c2f356ebb51c32f4da13 (patch)
treee3d25f29c3b8b06bac1116741f67ae4e35d24cd8 /Lib/copy.py
parent030afb1d3a86196be85b51f2174b5796a93eb07d (diff)
downloadcpython-55d2f3997e208a290ee3c2f356ebb51c32f4da13.zip
cpython-55d2f3997e208a290ee3c2f356ebb51c32f4da13.tar.gz
cpython-55d2f3997e208a290ee3c2f356ebb51c32f4da13.tar.bz2
rename copy.Error to copy.error
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 966bfa2..3bbf3e7 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -9,7 +9,7 @@ Interface summary:
x = copy.copy(y) # make a shallow copy of y
x = copy.deepcopy(y) # make a deep copy of y
-For module specific errors, copy.Error is raised.
+For module specific errors, copy.error is raised.
The difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
@@ -52,7 +52,8 @@ __getstate__() and __setstate__(). See the __doc__ string of module
import types
-Error = 'copy.Error'
+error = 'copy.error'
+Error = error # backward compatibility
def copy(x):
"""Shallow copy operation on arbitrary Python objects.
@@ -66,7 +67,7 @@ def copy(x):
try:
copier = x.__copy__
except AttributeError:
- raise Error, \
+ raise error, \
"un(shallow)copyable object of type %s" % type(x)
y = copier()
else:
@@ -85,6 +86,7 @@ d[types.StringType] = _copy_atomic
d[types.CodeType] = _copy_atomic
d[types.TypeType] = _copy_atomic
d[types.XRangeType] = _copy_atomic
+d[types.ClassType] = _copy_atomic
def _copy_list(x):
return x[:]
@@ -140,7 +142,7 @@ def deepcopy(x, memo = None):
try:
copier = x.__deepcopy__
except AttributeError:
- raise Error, \
+ raise error, \
"un-deep-copyable object of type %s" % type(x)
y = copier(memo)
else:
@@ -220,7 +222,8 @@ del d
del types
def _test():
- l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'], {'abc': 'ABC'}, (), [], {}]
+ l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],
+ {'abc': 'ABC'}, (), [], {}]
l1 = copy(l)
print l1==l
l1 = map(copy, l)