[ python-Bugs-1099746 ] copy.deepcopy barfs when copying a class
derived from dict
SourceForge.net
noreply at sourceforge.net
Mon Jan 10 22:28:19 CET 2005
Bugs item #1099746, was opened at 2005-01-10 21:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099746&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Doug Winter (winjer)
Assigned to: Nobody/Anonymous (nobody)
Summary: copy.deepcopy barfs when copying a class derived from dict
Initial Comment:
I've got a class:
class odict(dict):
def __init__(self, d={}):
self._keys = d.keys()
dict.__init__(self, d)
def __setitem__(self, key, item):
dict.__setitem__(self, key, item)
if key not in self._keys:
self._keys.append(key)
...
When I copy.deepcopy one of these it blows up in
__setitem__ with an AttributeError on _keys, because
__setitem__ is called without __init__ ever having been
called. Presumably this thing looks and smells like a
dictionary, so deepcopy thinks it is one.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099746&group_id=5470
More information about the Python-bugs-list
mailing list