You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot copy a class with a metaclass other than type #55689
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/avassalotti'closed_at=<Date2013-12-01.21:27:54.650>created_at=<Date2011-03-13.09:04:19.450>labels= ['type-bug', 'library']
title='Cannot copy a class with a metaclass other than type'updated_at=<Date2013-12-01.21:27:54.648>user='https://github.com/durban'
The reason seems to be, as described in msg8329 (bpo-494904) 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 bpo-7689.)
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).
Activity
durban commentedon Mar 13, 2011
copy.copy cannot copy a class which have a metaclass other than type:
The reason seems to be, as described in msg8329 (bpo-494904) 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 bpo-7689.)
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).
merwok commentedon Mar 18, 2011
Looks good to me.
durban commentedon Jun 3, 2012
I've updated the patch to the current version. I've also checked, that the tests still pass.
nailor commentedon Feb 24, 2013
Hi, to be able to include your patch, could you sign the contributor form, please: http://www.python.org/psf/contrib/ ?
durban commentedon Feb 24, 2013
I did, and I've been told that it has been added to the bug tracker: http://mail.python.org/pipermail/python-committers/2012-May/001987.html
nailor commentedon Feb 24, 2013
Oh, my bad. The * was not just showing next to your name. Maybe someone with more access rights can help?
python-dev commentedon Dec 1, 2013
New changeset c6bb6f304f75 by Alexandre Vassalotti in branch '3.3':
Issue bpo-11480: Fixed copy.copy to work with classes with custom metaclasses.
http://hg.python.org/cpython/rev/c6bb6f304f75
New changeset c4715c9f442f by Alexandre Vassalotti in branch 'default':
Issue bpo-11480: Merge with 3.3.
http://hg.python.org/cpython/rev/c4715c9f442f
avassalotti commentedon Dec 1, 2013
Thank you for the patch!