[Python-Dev] Python 2.5.1c1 pickle problem (original) (raw)
Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Apr 12 01:20:26 CEST 2007
- Previous message: [Python-Dev] svn.python.org
- Next message: [Python-Dev] Python 2.5.1c1 pickle problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
When pickling instances of an object derived from dict, the pickle in Python 2.5.1c1 calls the object's getitem() method. In contrast, earlier versions of Python incl. 2.5 don't call that method. Below is a minimal example with outputs. Is the difference in behavior an oversight or new feature? I couldn't find anything directly related in the release notes. The difference in behavior breaks some of our code. Thanks! Ralf
class user(dict):
def getitem(self, key): print "GETITEM", key
if (name == "main"): import sys print sys.version u = user() u[1] = 2 import pickle pickle.dumps(u) print "Done."
2.5.1c1 (r251c1:54692, Apr 11 2007, 16:15:52) [GCC 4.1.0 20060304 (Red Hat 4.1.0-3)] GETITEM 1 Done.
2.5 (r25:51908, Apr 11 2007, 16:11:19) [GCC 4.1.0 20060304 (Red Hat 4.1.0-3)] Done.
2.4.2 (#1, Feb 12 2006, 03:45:41) [GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] Done.
2.3.4 (#1, Oct 26 2004, 16:45:38) [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] Done.
2.2.1 (#1, Aug 30 2002, 12:15:30) [GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] Done.
No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20070411/1a27efc9/attachment.html
- Previous message: [Python-Dev] svn.python.org
- Next message: [Python-Dev] Python 2.5.1c1 pickle problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]