This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: deepcopy can't handle custom metaclasses
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: glchapman, gvanrossum
Priority: normal Keywords:

Created on 2002-05-26 19:15 by glchapman, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
copy.py.diff glchapman, 2002-05-26 19:15
copy.py.diff glchapman, 2002-05-26 19:35
Messages (3)
msg10933 - (view) Author: Greg Chapman (glchapman) Date: 2002-05-26 19:15
This is essentially the same problem as that reported in 
bug 494904 for pickle: deepcopy should treat instances 
of custom metaclasses the same way it treats 
instances of type 'type'.  I've attached a provisional fix 
which is basically a copy of the patch made to pickle (it 
checks to see if the type of the thing being deepcopied 
is a subclass of type).

One question: it seems to me that the exception 
handling code is unnecessary both here and in the 
pickle module.  In both cases, the first parameter to 
subclass is the result of a call to 'type' and the second 
is type 'type' itself, so it doesn't seem like there's any 
reason to worry about a TypeError.
msg10934 - (view) Author: Greg Chapman (glchapman) Date: 2002-05-26 19:35
Logged In: YES 
user_id=86307

I changed the patch so that issubclass is called before the 
attempt to access __deepcopy__ (to avoid unbound instance 
method problem methioned in 494904).
msg10935 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-10 21:10
Logged In: YES 
user_id=6380

Thanks; I've checked this in. For the reason of the except
clause, see python.org/sf/502085.
History
Date User Action Args
2022-04-10 16:05:21adminsetgithub: 36650
2002-05-26 19:15:21glchapmancreate