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
5c1c3b4f
Commit
5c1c3b4f
authored
Dec 01, 2013
by
Alexandre Vassalotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #11480: Fixed copy.copy to work with classes with custom metaclasses.
Patch by Daniel Urban.
parent
361e30c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
Lib/copy.py
Lib/copy.py
+8
-0
Lib/test/test_copy.py
Lib/test/test_copy.py
+4
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/copy.py
View file @
5c1c3b4f
...
...
@@ -76,6 +76,14 @@ def copy(x):
if
copier
:
return
copier
(
x
)
try
:
issc
=
issubclass
(
cls
,
type
)
except
TypeError
:
# cls is not a class
issc
=
False
if
issc
:
# treat it as a regular class:
return
_copy_immutable
(
x
)
copier
=
getattr
(
cls
,
"__copy__"
,
None
)
if
copier
:
return
copier
(
x
)
...
...
Lib/test/test_copy.py
View file @
5c1c3b4f
...
...
@@ -3,6 +3,7 @@
import
copy
import
copyreg
import
weakref
import
abc
from
operator
import
le
,
lt
,
ge
,
gt
,
eq
,
ne
import
unittest
...
...
@@ -93,9 +94,11 @@ class TestCopy(unittest.TestCase):
pass
def
f
():
pass
class
WithMetaclass
(
metaclass
=
abc
.
ABCMeta
):
pass
tests
=
[
None
,
42
,
2
**
100
,
3.14
,
True
,
False
,
1j
,
"hello"
,
"hello
\
u1234
"
,
f
.
__code__
,
NewStyle
,
range
(
10
),
Classic
,
max
]
NewStyle
,
range
(
10
),
Classic
,
max
,
WithMetaclass
]
for
x
in
tests
:
self
.
assertIs
(
copy
.
copy
(
x
),
x
)
...
...
Misc/NEWS
View file @
5c1c3b4f
...
...
@@ -24,6 +24,9 @@ Library
- Fixed _pickle.Unpickler to not fail when loading empty strings as
persistent IDs.
- Issue #11480: Fixed copy.copy to work with classes with custom metaclasses.
Patch by Daniel Urban.
- Issue #6477: Added support for pickling the types of built-in singletons
(i.e., Ellipsis, NotImplemented, None).
...
...
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