New submission from Daniel Urban <urban.dani...@gmail.com>: copy.copy cannot copy a class which have a metaclass other than type:
>>> import abc >>> import copy >>> >>> class C(metaclass=abc.ABCMeta): ... pass ... >>> copy.copy(C) Traceback (most recent call last): ... TypeError: can't pickle int objects The reason seems to be, as described in msg8329 (issue494904) that the __reduce_ex__ function inherited from object will be called instead of the method bound to the class object (that's the reason of the strange error message). (See also issue7689.) The interesting thing is, that copy.deepcopy was already fixed in 4680ef4fe90a. I'm attaching a patch, that does basically the same for copy that was done with deepcopy (it also includes a test). ---------- components: Library (Lib) files: copy_metaclass.patch keywords: patch messages: 130731 nosy: durban priority: normal severity: normal status: open title: Cannot copy a class with a metaclass other than type type: behavior versions: Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file21100/copy_metaclass.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11480> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com