[issue19834] Unpickling exceptions pickled by Python 2

Walter Dörwald report at bugs.python.org
Fri Nov 29 16:49:14 CET 2013


New submission from Walter Dörwald:

Exception objects that have been pickled with Python 2 can not be unpickled with Python 3, even when fix_imports=True is specified:

  $ python2.7
  Python 2.7.2 (default, Aug 30 2011, 11:04:13)
  [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import pickle
  >>> pickle.dumps(StopIteration())
  'cexceptions\nStopIteration\np0\n(tRp1\n.'
  >>>
  $ python3.3
  Python 3.3.2 (default, Nov 14 2013, 12:22:14)
  [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import pickle
  >>> pickle.loads(b'cexceptions\nStopIteration\np0\n(tRp1\n.', fix_imports=True)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ImportError: No module named 'exceptions'
  >>>

Adding an entry "exceptions": "builtins" to _compat_pickle.IMPORT_MAPPING seems to fix the problem.

----------
messages: 204733
nosy: doerwalter
priority: normal
severity: normal
status: open
title: Unpickling exceptions pickled by Python 2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19834>
_______________________________________


More information about the Python-bugs-list mailing list