[mod_python] Problem with mod_python.cgihandler in Python 2.2?

Moore, Paul Paul.Moore at atosorigin.com
Fri Apr 4 11:53:20 EST 2003


I just tried out a CGI script under the cgihandler with mod_python 3.0.3.

I got an error as follows (wrapped for readability):

[Fri Apr 04 11:23:59 2003] [error] [client 127.0.0.1]
PythonHandler mod_python.cgihandler:
Traceback (most recent call last): 
[Fri Apr 04 11:23:59 2003] [error] [client 127.0.0.1]
PythonHandler mod_python.cgihandler:
File "C:\Python22\lib\site-packages\mod_python\apache.py",
line 335, in HandlerDispatch
    result = object(req)
[Fri Apr 04 11:23:59 2003] [error] [client 127.0.0.1]
PythonHandler mod_python.cgihandler:
File "C:\Python22\lib\site-packages\mod_python\cgihandler.py",
line 140, in handler
    apache.restore_nocgi(env, si, so)
[Fri Apr 04 11:23:59 2003] [error] [client 127.0.0.1]
PythonHandler mod_python.cgihandler:
File "C:\Python22\lib\site-packages\mod_python\apache.py",
line 764, in restore_nocgi
    for k in osenv: 

It looks to me like the code at line 764 in apache.py is wrong -

    for k in osenv:
        del osenv[k]

should be

    for k in osenv.keys():
        del osenv[k]

Otherwise, you're modifying the osenv dictionary while you're
iterating over it. Python 2.2.2 seems to have made this an error,
rather than letting it pass (and possibly giving incorrect
results).

At least, I made the above change, and started getting errors from
my script and Apache config, rather than from mod_python :-)

Paul.




More information about the Mod_python mailing list