gnb at itga.com.au
Fri Dec 20 17:33:18 EST 2002
[FreeBSD 4.7, python 2.2.2, Apache 2.0.43, mod_python 3.0.1] When I try and run something using cgihandler, I get the following error: [Fri Dec 20 16:54:25 2002] [error] [client 192.168.71.163] PythonHandler mod_python.cgihandler: File "/usr/local/lib/python2.2/site-packages/mod_python/apache.py", line 764, in restore_nocgi for k in osenv: [Fri Dec 20 16:54:25 2002] [error] [client 192.168.71.163] PythonHandler mod_python.cgihandler: RuntimeError: dictionary changed size during iteration Looking at mod_python/apache.py:restore_nocgi(), this does: for k in osenv: del osenv[k] This is never going to be legal in Python 2.2. Shouldn't this be for k in osenv.keys(): del osenv[k] ? Having made that change, and a few little fixes to the cgi program, (__name__ == "__main__" is no longer true, "foo-bar.py" is not a good name as "import foo-bar" is a syntax error) my cgi now runs inside mod_python. But the HTML generated by the CGI is sent twice, so my page displays double. I've added debugging and the HTML is only being sent from the script once, as far as I can tell. (i.e. I print a string of length 2132 bytes, but View Page Info shows 4215 bytes. No, I have no idea where the missing 49 bytes are!) Any clues? Greg.