[Python-bugs-list] [ python-Bugs-560794 ] deepcopy can't handle custom metaclasses
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 10 Jun 2002 14:10:39 -0700
Bugs item #560794, was opened at 2002-05-26 15:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=560794&group_id=5470
Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Guido van Rossum (gvanrossum)
Summary: deepcopy can't handle custom metaclasses
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-10 17:10
Message:
Logged In: YES
user_id=6380
Thanks; I've checked this in. For the reason of the except
clause, see python.org/sf/502085.
----------------------------------------------------------------------
Comment By: Greg Chapman (glchapman)
Date: 2002-05-26 15:35
Message:
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).
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=560794&group_id=5470