[Python-bugs-list] [ python-Bugs-767228 ] Pickle (cPickle) __getinitargs__ problem in 2.3b2 ?

SourceForge.net noreply@sourceforge.net
Tue, 08 Jul 2003 05:21:31 -0700


Bugs item #767228, was opened at 2003-07-07 17:18
Message generated for change (Settings changed) made by jhylton
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=767228&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Gregor Mirai (gmirai)
Assigned to: Jeremy Hylton (jhylton)
Summary: Pickle (cPickle) __getinitargs__ problem in 2.3b2 ?

Initial Comment:
The following code works correctly with 2.3b1 (on MacOS 
X), but it throws KeyError: __getinitargs__ with 2.3b2 :

--------------------------------------------
#!/usr/bin/env python
import cPickle as c

class Style:
   def __init__(self):
      self.d = {}

   def __setitem__(self, key, value):
      self.d["d_"+key]=value

   def __getattr__(self, key):
      if key.startswith("d_"):
         return self.d[key]    
      else:
         return self.__dict__[key]

s = Style()
s["A"] = "B"

print s.d_A
print c.dumps(s)
--------------------------------------------

The problem shows with any class that should override 
__getattr__ attribute.

So it seems that pickle is broken in the new release ?


----------------------------------------------------------------------

>Comment By: Jeremy Hylton (jhylton)
Date: 2003-07-08 12:21

Message:
Logged In: YES 
user_id=31392

This isn't a bug after all.  cPickle and pickle now produce
the same results, which is a KeyError.  The __getattr__()
method in the example code is incorrect, because it raises
KeyError for missing attributes instead of AttributeError.


----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2003-07-07 19:14

Message:
Logged In: YES 
user_id=31392

I probably broke something in change that catches only
specific exceptions.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=767228&group_id=5470