[ python-Bugs-1675967 ] Python2.5 can't read a (complex) pickle build by python2.4

SourceForge.net noreply at sourceforge.net
Sun Mar 11 16:40:13 CET 2007


Bugs item #1675967, was opened at 2007-03-07 19:16
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1675967&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Vogt (mvo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Python2.5 can't read a (complex) pickle build by python2.4

Initial Comment:
Part of gnome-app-install in ubuntu is a pickle data structure cache. If I create this pickle with python 2.4 and read it later with 2.5. I get the following error:

$ python2.5 -c 'import pickle; pickle.load(open("/var/cache/app-install/menu.p"))'
/usr/lib/python2.5/pickle.py:1124: DeprecationWarning: The sre module is deprecated, please import re.
  __import__(module)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.5/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python2.5/pickle.py", line 1126, in find_class
    klass = getattr(mod, name)
AttributeError: 'module' object has no attribute '_compile'

With:
$ python2.4 -c 'import pickle; pickle.load(open("/var/cache/app-install/menu.p"))'
egon at top ~ $ 

It loads just fine. 

The test pickle can be found here:
http://people.ubuntu.com/~mvo/gnome-app-install/menu.p.gz

Cheers,
 Michael

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

>Comment By: Žiga Seilnacht (zseil)
Date: 2007-03-11 16:40

Message:
Logged In: YES 
user_id=1326842
Originator: NO

Attaching the patch with a test here. Unpickling
old patterns with this patch works, but it still
issues a DeprecationWarning. The test itself is
a bit obscure, but the other option is to add
a binary file to the test suite.
File Added: sre_pickle_compatibility.diff

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

Comment By: Žiga Seilnacht (zseil)
Date: 2007-03-07 20:43

Message:
Logged In: YES 
user_id=1326842
Originator: NO

This happens because of SRE_Pattern objects in jour pickle.
The sre module was renamed to re in Python 2.5, but the
old pickles still expect the _compile function in sre module.
I posted the patch here:

http://freeweb.siol.net/chollus/

Could you try if it fixes the problem for you and in that
case, attach it to this report?

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

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


More information about the Python-bugs-list mailing list