summaryrefslogtreecommitdiffstats
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2013-12-01 21:25:26 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2013-12-01 21:25:26 (GMT)
commit5c1c3b4f197c57952760be37d77d73669284a607 (patch)
treea9ab8c86fa593dabb5a39b6b5fe797ef5ed47b02 /Lib/copy.py
parent361e30c17a7973874334597903afb3ba5a477f49 (diff)
downloadcpython-5c1c3b4f197c57952760be37d77d73669284a607.zip
cpython-5c1c3b4f197c57952760be37d77d73669284a607.tar.gz
cpython-5c1c3b4f197c57952760be37d77d73669284a607.tar.bz2
Issue #11480: Fixed copy.copy to work with classes with custom metaclasses.
Patch by Daniel Urban.
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index d96201e..d26bcdb 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -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)