Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
55d2f399
Commit
55d2f399
authored
Mar 14, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename copy.Error to copy.error
parent
030afb1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
Lib/copy.py
Lib/copy.py
+8
-5
No files found.
Lib/copy.py
View file @
55d2f399
...
...
@@ -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.
E
rror is raised.
For module specific errors, copy.
e
rror 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
E
rror
,
\
raise
e
rror
,
\
"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
E
rror
,
\
raise
e
rror
,
\
"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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment