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.

Author orsenthil
Recipients gvanrossum, orsenthil
Date 2013-10-01.18:06:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
FieldStorage("foo", "bar") is invalid because the first argument is supposed to
be file-like object and second one headers. Here we are sending invalid headers. By
default, if the headers is none, the content-type is urlencoded.

The right way of using FieldStorage is either using the keyword arguments in a tightly couple manner. Or use it as default instance (fs = cgi.FieldStorage())

So the expectation could be:

>>>fs = cgi.FieldStorage()

>>> # sending correct fs, env
>>> #
>>> fs = cgi.FieldStorage(fs, environ=env)
>>> bool(fs)

The TypeError failure in python3 for bool(fs) is, in the absence of __bool__, it is trying to do
a len() and which ultimately ends up calling keys():

The proper fix in Python3 IMO is the just define __bool__ instead of __nonzero__ and that will be return False instead of TypeError.
Date User Action Args
2013-10-01 18:06:26orsenthilsetrecipients: + orsenthil, gvanrossum
2013-10-01 18:06:26orsenthilsetmessageid: <>
2013-10-01 18:06:26orsenthillinkissue19097 messages
2013-10-01 18:06:26orsenthilcreate