Bug Report / Patch (1159139 cgi.py invalid REQUEST_METHOD set)

J

Joe

Back in March I submitted a patch for cgi.py to sourceforge to fix a problem
with the handling of an invalid REQUEST_METHOD.

I thought I followed all the steps to properly submit the bug and patch but
the patch is still sitting there in limbo.

This is the first patch I have submitted for Python, did I miss a step in
the patch process?

What else needs to be done?

Thanks!
 
R

Reinhold Birkenfeld

Joe said:
Back in March I submitted a patch for cgi.py to sourceforge to fix a problem
with the handling of an invalid REQUEST_METHOD.

I thought I followed all the steps to properly submit the bug and patch but
the patch is still sitting there in limbo.

This is the first patch I have submitted for Python, did I miss a step in
the patch process?

What else needs to be done?

Can you provide an example script demonstrating the problem you describe?

I tried something like this (Py2.4.1):

------- test_cgi.py
#!/bin/env python
import cgi
fs = cgi.FieldStorage()
print fs

$ python test_cgi.py "a=1&b=2"
FieldStorage(None, None, [MiniFieldStorage('a', '1'), MiniFieldStorage('b', '2')])
$

There's no REQUEST_METHOD or QUERY_STRING env var set.

Reinhold
 
S

Steven Bethard

Joe said:
Back in March I submitted a patch for cgi.py to sourceforge to fix a problem
with the handling of an invalid REQUEST_METHOD.

I thought I followed all the steps to properly submit the bug and patch but
the patch is still sitting there in limbo.

Patches get processed when people have the time to review them.

If you'd like to speed up the process, a few people on the python-dev
list have promised to review a patch if the requester reviews 5 other
patches. So if you want to get your patch looked at:

(1) pick 5 other patches
(2) try them on your system
(3) make a helpful comment on each of the patch trackers
(4) send a summary of your reviews to the python-dev list, along with a
link to the patch you'd like reviewed.

HTH,

STeVe
 
J

Joe

Reinhold,

Thanks for responding...

I see that you are using Python 2.4.1 and the bug was against 2.4. (I am
now using 2.4.1)

If I remember correctly there were two issues that I ran into, one was with
a missing REQUEST_METHOD and the other was with a INCORRECT request method.
As per your example the missing one does not seem to be a problem any
longer.

The incorrect REQUEST_METHOD setting still seems to be an issue with Python
2.4.1.

Make the following changes to your code to demonstrate that problem.

import cgi
import os # NEW

os.environ['REQUEST_METHOD'] = 'cgi' # NEW

field = cgi.FieldStorage()

print field
print field.keys() # NEW

Run the program now with NO parameters. (I'm running on WinXP SP2).

After you start the program cgi.py will be reading from stdin.

type "a=1" and hit enter
type "b=2" and hit enter
press ctrl-z (to send eof) and hit enter

You will get the following stack trace.

FieldStorage(None, None, 'a=1\nb=2\n')
Traceback (most recent call last):
File "H:\1\t2.py", line 12, in ?
print field.keys()
File "P:\SW\Python\lib\cgi.py", line 601, in keys
TypeError: not indexable

When the environment does not have a correctly set REQUEST_METHOD cgi.py
prompts
for key=value pairs by reading from sys.stdin. (as demonstrated above) I
realize REQUEST_METHOD
should be set properly but hear me out.

After the values are read from sys.stdin they are never stored in the
FieldStorage.list attribute like they are
when the FieldStorage.read_urlencoded or FieldStorage.read_multi methods are
called. The read_single
method is the one that has the problem (it is inconsistenty with the other
two methods because it doesn't
store the values like the other two methods do).

This causes a problem when FieldStorage.keys() is called because although
the values were read from
sys.stdin they were never stored in FieldStorage.list.

Although you could argue that REQUEST_METHOD should have been set correctly
in the first place, it still
seems like if cgi.py is going to handle that situation of a invalid
REQUEST_METHOD by actually reading the
values from sys.stdin (it already does this part) it should store them too
(especially since it does store the values in the other two methods).

Does that explain the issue more clearly?


Reinhold Birkenfeld said:
Joe said:
Back in March I submitted a patch for cgi.py to sourceforge to fix a
problem
with the handling of an invalid REQUEST_METHOD.

I thought I followed all the steps to properly submit the bug and patch
but
the patch is still sitting there in limbo.

This is the first patch I have submitted for Python, did I miss a step in
the patch process?

What else needs to be done?

Can you provide an example script demonstrating the problem you describe?

I tried something like this (Py2.4.1):

------- test_cgi.py
#!/bin/env python
import cgi
fs = cgi.FieldStorage()
print fs

$ python test_cgi.py "a=1&b=2"
FieldStorage(None, None, [MiniFieldStorage('a', '1'),
MiniFieldStorage('b', '2')])
$

There's no REQUEST_METHOD or QUERY_STRING env var set.

Reinhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top