Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55d2f39

Browse files
committed
rename copy.Error to copy.error
1 parent 030afb1 commit 55d2f39

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Lib/copy.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
x = copy.copy(y) # make a shallow copy of y
1010
x = copy.deepcopy(y) # make a deep copy of y
1111
12-
For module specific errors, copy.Error is raised.
12+
For module specific errors, copy.error is raised.
1313
1414
The difference between shallow and deep copying is only relevant for
1515
compound objects (objects that contain other objects, like lists or
@@ -52,7 +52,8 @@ class instances).
5252

5353
import types
5454

55-
Error = 'copy.Error'
55+
error = 'copy.error'
56+
Error = error # backward compatibility
5657

5758
def copy(x):
5859
"""Shallow copy operation on arbitrary Python objects.
@@ -66,7 +67,7 @@ def copy(x):
6667
try:
6768
copier = x.__copy__
6869
except AttributeError:
69-
raise Error, \
70+
raise error, \
7071
"un(shallow)copyable object of type %s" % type(x)
7172
y = copier()
7273
else:
@@ -85,6 +86,7 @@ def _copy_atomic(x):
8586
d[types.CodeType] = _copy_atomic
8687
d[types.TypeType] = _copy_atomic
8788
d[types.XRangeType] = _copy_atomic
89+
d[types.ClassType] = _copy_atomic
8890

8991
def _copy_list(x):
9092
return x[:]
@@ -140,7 +142,7 @@ def deepcopy(x, memo = None):
140142
try:
141143
copier = x.__deepcopy__
142144
except AttributeError:
143-
raise Error, \
145+
raise error, \
144146
"un-deep-copyable object of type %s" % type(x)
145147
y = copier(memo)
146148
else:
@@ -220,7 +222,8 @@ def _deepcopy_inst(x, memo):
220222
del types
221223

222224
def _test():
223-
l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'], {'abc': 'ABC'}, (), [], {}]
225+
l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],
226+
{'abc': 'ABC'}, (), [], {}]
224227
l1 = copy(l)
225228
print l1==l
226229
l1 = map(copy, l)

0 commit comments

Comments
 (0)