diff -r e34b09c69dd3 Lib/copy.py --- a/Lib/copy.py Sat Mar 12 22:31:06 2011 -0500 +++ b/Lib/copy.py Sun Mar 13 10:00:44 2011 +0100 @@ -76,6 +76,14 @@ 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) diff -r e34b09c69dd3 Lib/test/test_copy.py --- a/Lib/test/test_copy.py Sat Mar 12 22:31:06 2011 -0500 +++ b/Lib/test/test_copy.py Sun Mar 13 10:00:44 2011 +0100 @@ -3,6 +3,7 @@ import copy import copyreg import weakref +import abc from operator import le, lt, ge, gt, eq, ne import unittest @@ -87,9 +88,11 @@ 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.assertTrue(copy.copy(x) is x, repr(x))