Message130731
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). |
|
Date |
User |
Action |
Args |
2011-03-13 09:04:20 | daniel.urban | set | recipients:
+ daniel.urban |
2011-03-13 09:04:19 | daniel.urban | set | messageid: <1300007060.0.0.461224143225.issue11480@psf.upfronthosting.co.za> |
2011-03-13 09:04:19 | daniel.urban | link | issue11480 messages |
2011-03-13 09:04:19 | daniel.urban | create | |
|