classification
Title: marshal_loads can return NULL without setting Error
Type: enhancement Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, skip.montanaro
Priority: high Keywords:

Created on 2000-09-18 22:46 by skip.montanaro, last changed 2000-09-19 01:30 by gvanrossum. This issue is now closed.

Messages (2)
msg1438 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2000-09-18 22:46
I'm getting a NULL result from marshal_loads without it
setting an error. (This is in 1.5.2 and 2.0b1.)  I'm pretty 
sure the input being fed to marshal.loads is bad, but it 
still should still doing the error handling dance correctly, 
yes?  Here's a simple example:

    >>> import marshal
    >>> x = marshal.loads('006@mediaone.net.weekly.529454')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    SystemError: NULL result without error in call_object

It looks like r_object returns NULL if type == '0' and then 
marshal_loads simply returns it without checking the value 
returned by r_object.  If this is a "feature" and not a
bug, there should at least be a comment in the TYPE_NULL
branch of the switch statement indicating why it's not an
error to return NULL without setting an exception.

(P.S.  Is there any search facility within the SF bug manager or are you stuck having to wade through all bugs to
find out if yours has already been reported?)
msg1439 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-09-19 01:30
Marshal is not very careful in validating its input -- it was written for speedy reading of .pyc files only. I agree that this should be fixed. Since a spurious '0' input character probably isn't the only bad input that it might choke on (it could even dump core!) I'm not going to fix this, but I'll add a feature request to PEP 42: better checking for bad input to marshal.load*().
History
Date User Action Args
2000-09-18 22:46:37skip.montanarocreate