This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python2.5 can't read a (complex) pickle build by python2.4
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zseil Nosy List: mvo, zseil
Priority: normal Keywords:

Created on 2007-03-07 18:16 by mvo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sre_pickle_compatibility.diff zseil, 2007-03-11 15:40 patch against trunk revision 54249
Messages (5)
msg31460 - (view) Author: Michael Vogt (mvo) * Date: 2007-03-07 18:16
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@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
msg31461 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-03-07 19:43
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?
msg31462 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-03-11 15:40
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
msg31463 - (view) Author: Michael Vogt (mvo) * Date: 2007-03-21 09:43
Thanks a lot for the patch. It works fine here with the patch.
msg31464 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-03-21 20:41
The patch was commited as revision 54492, 54497 (2.5).
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44678
2007-03-07 18:16:08mvocreate