Mercurial > cpython-lru_cache-weakref
changeset 87682:c4715c9f442f
Issue #11480: Merge with 3.3.
| author | Alexandre Vassalotti <alexandre@peadrop.com> |
|---|---|
| date | Sun, 01 Dec 2013 13:26:32 -0800 |
| parents | 84148898a606 (current diff) c6bb6f304f75 (diff) |
| children | 2df5e1f537b0 |
| files | Lib/copy.py Misc/NEWS |
| diffstat | 3 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/copy.py Sun Dec 01 14:30:47 2013 +0100 +++ b/Lib/copy.py Sun Dec 01 13:26:32 2013 -0800 @@ -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)
--- a/Lib/test/test_copy.py Sun Dec 01 14:30:47 2013 +0100 +++ b/Lib/test/test_copy.py Sun Dec 01 13:26:32 2013 -0800 @@ -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 @@ 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)
--- a/Misc/NEWS Sun Dec 01 14:30:47 2013 +0100 +++ b/Misc/NEWS Sun Dec 01 13:26:32 2013 -0800 @@ -33,6 +33,9 @@ - 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).
