Hello All,

I subclassed dict and overrode __setitem__. When instances are unpickled, the __setstate__ is not called before the keys are assigned via __setitem__ in the unpickling protocol.

I googled a bit and found that this a bug filed in 2003:

http://bugs.python.org/issue826897

It is still "open" with "normal" priority.

Am I missing something? Is there a workaround for this bug that makes fixing it pointless or has it just fallen through the cracks for the last 5 years?

Here is an example:

class DictPlus(dict):
  def __init__(self, *args, **kwargs):
    self.extra_thing = ExtraThingClass()
    dict.__init__(self, *args, **kwargs)
  def __setitem__(self, k, v):
    do_something_with(self.extra_thing, k, v)
    dict.__setitem__(self, k, v)

Upon unpickling, the error would be:

AttributeError: 'DictPlus' object has no attribute 'extra_thing'


I'm still using python 2.5.1.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to