[ python-Bugs-1497319 ] Pickling exceptions crashes Python

SourceForge.net noreply at sourceforge.net
Tue May 30 10:35:24 CEST 2006


Bugs item #1497319, was opened at 2006-05-30 07:29
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1497319&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 Interpreter Core
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Žiga Seilnacht (zseil)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling exceptions crashes Python

Initial Comment:
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.

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

>Comment By: Žiga Seilnacht (zseil)
Date: 2006-05-30 10:35

Message:
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')


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

Comment By: Žiga Seilnacht (zseil)
Date: 2006-05-30 10:20

Message:
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.

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

Comment By: Georg Brandl (gbrandl)
Date: 2006-05-30 09:35

Message:
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.

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

Comment By: Georg Brandl (gbrandl)
Date: 2006-05-30 09:13

Message:
Logged In: YES 
user_id=849994

Thanks! Fixed in rev. 46551, added a test case.

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

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


More information about the Python-bugs-list mailing list