[Patches] [ python-Patches-1498571 ] Correctly unpickle exceptions
SourceForge.net
noreply at sourceforge.net
Thu Jun 1 08:39:40 CEST 2006
Patches item #1498571, was opened at 2006-05-31 23:21
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1498571&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: Core (C code)
Group: Python 2.5
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: iga Seilnacht (zseil)
Assigned to: Nobody/Anonymous (nobody)
Summary: Correctly unpickle exceptions
Initial Comment:
With recent changes to exception types, unpickling
exceptions that were pickled with an older version
of Python didn't restore all of the original
attributes. Example:
Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
...
>>> import pickle
>>> f = open('jar', 'wb')
>>> e = Exception('cucumbers', 'cabbage')
>>> e.args
('cucumbers', 'cabbage')
>>> pickle.dump(e, f)
>>> f.close()
>>> f = open('jar', 'rb')
>>> e = pickle.load(f)
>>> f.close()
>>> e.args
('cucumbers', 'cabbage')
Python 2.5a2 (trunk:46539M, May 30 2006, 05:02:24)
...
>>> import pickle
>>> f = open('jar', 'rb')
>>> e = pickle.load(f)
>>> f.close()
>>> e.args
()
>>> e.__dict__['args']
('cucumbers', 'cabbage')
The attached patch fixes this problem, by adding
a __setstate__ method to BaseException. I don't
know if any new tests are needed, since pickling
exceptions is already tested and new tests would
require adding binary files to the test suite.
I did some basic tests that I can attach if
they are needed.
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2006-06-01 06:39
Message:
Logged In: YES
user_id=849994
Applied as rev. 46585. Thanks!
----------------------------------------------------------------------
Comment By: iga Seilnacht (zseil)
Date: 2006-06-01 01:44
Message:
Logged In: YES
user_id=1326842
Removed unnecessary cast.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1498571&group_id=5470
More information about the Patches
mailing list