[Python-checkins] python/dist/src/Lib copy.py,1.27,1.28
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Mon, 10 Jun 2002 14:10:30 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv27967
Modified Files:
copy.py
Log Message:
SF patch 560794 (Greg Chapman): deepcopy can't handle custom
metaclasses.
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'.
Bugfix candidate.
Index: copy.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** copy.py 6 Jun 2002 17:41:20 -0000 1.27
--- copy.py 10 Jun 2002 21:10:27 -0000 1.28
***************
*** 165,179 ****
except KeyError:
try:
! copier = x.__deepcopy__
! except AttributeError:
try:
! reductor = x.__reduce__
except AttributeError:
! raise error, \
! "un-deep-copyable object of type %s" % type(x)
else:
! y = _reconstruct(x, reductor(), 1, memo)
! else:
! y = copier(memo)
else:
y = copierfunction(x, memo)
--- 165,186 ----
except KeyError:
try:
! issc = issubclass(type(x), type)
! except TypeError:
! issc = 0
! if issc:
! y = _deepcopy_dispatch[type](x, memo)
! else:
try:
! copier = x.__deepcopy__
except AttributeError:
! try:
! reductor = x.__reduce__
! except AttributeError:
! raise error, \
! "un-deep-copyable object of type %s" % type(x)
! else:
! y = _reconstruct(x, reductor(), 1, memo)
else:
! y = copier(memo)
else:
y = copierfunction(x, memo)