[Python-bugs-list] [ python-Bugs-834840 ] Unhelpful error message from cgi module

SourceForge.net noreply at sourceforge.net
Sun Nov 2 21:54:39 EST 2003


Bugs item #834840, was opened at 2003-11-02 20:54
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=834840&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthew Cowles (mdcowles)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unhelpful error message from cgi module

Initial Comment:
[From a post to python-help]

If an instance of the cgi module's FieldStorage class doesn't 
recognize the HTTP request it's trying to parse as a form, no 
error is raised but attempting to access any of the form data 
later raises the unhelpful exception TypeError, "not 
indexable".

It seems that even Andrew Kuchling was once confused by 
this behavior:

http://groups.yahoo.com/group/web-sig/message/28

It happens because in the FieldStorage class's __init__(), the 
request's content-type is tested against "multipart/" and 
"application/x-www-form-urlencoded". If it doesn't match 
either of those, read_single() is called. In that case, self.list 
isn't changed from its default of None. That causes any call 
to __getitem__() to raise TypeError, "not indexable".

I'm no CGI expert, but I don't see the value of 
read_single(). As far as I can tell, it would make sense to 
raise TypeError (or perhaps ValueError) at that point with a 
message something like, "Data not recognized as a form".


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

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



More information about the Python-bugs-list mailing list