[ python-Bugs-1015249 ] cgi.FieldStorage.__len__ eventually throws TypeError

SourceForge.net noreply at sourceforge.net
Mon Aug 30 16:47:53 CEST 2004


Bugs item #1015249, was opened at 2004-08-24 15:32
Message generated for change (Comment added) made by jlgijsbers
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1015249&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Andreas Ames (yxcv)
Assigned to: Nobody/Anonymous (nobody)
Summary: cgi.FieldStorage.__len__ eventually throws TypeError

Initial Comment:
This makes it hazardous to do the following:

fs = cgi.FieldStorage(...)
if fs:
 ...

Suggestions:

1)  Fix __len__; sorry, but I don't know how.

2) Create FieldStorage.__nonzero__; a hack.

3) ?


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

>Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-08-30 16:47

Message:
Logged In: YES 
user_id=469548

As far as I can tell, cgi.FieldStorage.__len__ only raises a
TypeError if the FieldStorage is not indexable. It's
reasonable not to support len() on an unindexable FieldStorage.

I'm just wondering why you would want to do:

fs = cgi.FieldStorage(...)
if fs:
...

Defining __nonzero__ seems reasonable if there's a reason
for testing a FieldStorage for truth value.

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

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


More information about the Python-bugs-list mailing list