[Python-Dev] deepcopy
Amaury Forgeot d'Arc
amauryfa at gmail.com
Fri Jun 27 13:56:54 CEST 2008
Walter Bender wrote:
Hello togehter,
>
> I get an error while doing a deep copy of an "event". An event is an object,
> with has a lot of __dict__["attr"] = Event("SAMPLE") OTHER Events added to
> the object (no self refence) and store additional __dict__["attr2"] = 2
> informations.
>
> deep copy is failing with no proper error message.
>
>
> nevent = copy.deepcopy(event);
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 174, in deepcopy
> y = copier(x, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 305, in _deepcopy_inst
> state = deepcopy(state, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 174, in deepcopy
> y = copier(x, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 268, in _deepcopy_dict
> y[deepcopy(key, memo)] = deepcopy(value, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 174, in deepcopy
> y = copier(x, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 241, in _deepcopy_list
> y.append(deepcopy(a, memo))
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 174, in deepcopy
> y = copier(x, memo)
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 241, in _deepcopy_list
> y.append(deepcopy(a, memo))
> File
> "/net/software_cms/slc4_ia32_gcc345/external/python/2.4.2-CMS3q/lib/python2.4/copy.py",
> line 185, in deepcopy
> y = copier(x, memo)
> TypeError: __deepcopy__() takes no arguments (1 given
It's possible that "event" contains an object that cannot be copied.
>From the traceback, one can see that your object has an attribute that
is a list of lists, and the failing object is there.
Googling for the error message suggests that the object could be an
array.array.
The corresponding problem was corrected with python 2.4.4.
--
Amaury Forgeot d'Arc
More information about the Python-Dev
mailing list