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: Unhelpful error message from cgi module
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, akuchling, eric.araujo, ezio.melotti, mdcowles, orsenthil
Priority: low Keywords: easy

Created on 2003-11-03 02:54 by mdcowles, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg60415 - (view) Author: Matthew Cowles (mdcowles) Date: 2003-11-03 02:54
[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".
msg109263 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-04 20:30
Could a CGI expert pick this up, failing that why not simply close it as opened nearely 7 years ago.
msg114294 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-18 23:04
Closed as no reply to msg109263.
History
Date User Action Args
2022-04-11 14:56:00adminsetgithub: 39490
2013-11-06 20:22:48akuchlingsetstatus: open -> closed
resolution: wont fix
2012-11-09 12:44:49ezio.melottisetnosy: + akuchling, ezio.melotti
type: enhancement -> behavior
2010-11-18 02:14:28eric.araujosetnosy: + eric.araujo, - BreamoreBoy
2010-08-18 23:04:54BreamoreBoysetmessages: + msg114294
2010-07-05 11:49:39eric.araujosetnosy: + orsenthil
2010-07-04 20:30:38BreamoreBoysetnosy: + BreamoreBoy
messages: + msg109263
2009-04-22 17:20:34ajaksu2setkeywords: + easy
versions: + Python 2.7
2009-02-13 04:45:34ajaksu2setpriority: normal -> low
nosy: + ajaksu2
type: enhancement
stage: test needed
2003-11-03 02:54:39mdcowlescreate