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: Pickling exceptions crashes Python
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, zseil
Priority: normal Keywords:

Created on 2006-05-30 05:29 by zseil, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_exceptiontypes.py zseil, 2006-05-30 05:29 unittests
Messages (5)
msg28679 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-05-30 05:29
The crash happens if an Exception doesn't
have a dict, in BaseException_reduce.
Example:

Python 2.5a2 (trunk:46539M, May 30 2006, 05:02:24)
[MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license"
for more information.
>>> import pickle
>>> e = BaseException()
>>> pickle.dumps(e) # crash

I'm attaching a module with this and some
other failing tests, mostly caused by
backward incompatibilities. All of the
tests pass on 2.5a2.
msg28680 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-30 07:13
Logged In: YES 
user_id=849994

Thanks! Fixed in rev. 46551, added a test case.
msg28681 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-30 07:35
Logged In: YES 
user_id=849994

Added another test for kw args in rev. 46553.

That args can only be an iterable and will, once assigned,
always be a tuple, was a decision we made.
msg28682 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-05-30 08:20
Logged In: YES 
user_id=1326842

The _PyArg_NoKeywords check should probably be in
BaseException_init, not in BaseException_new, so
that subclasses that want keyword arguments don't
have to override two methods.
msg28683 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-05-30 08:35
Logged In: YES 
user_id=1326842

Oh, and another thing, unpickling exceptions
that were pickled with an older version
of Python will have strange effects:

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')
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43433
2006-05-30 05:29:12zseilcreate