views:

16

answers:

0

I'm using http.server with the CGIHTTPRequestHandler on OS X 10.6 and the posix code path in run_cgi() does not appear to work properly. I'm calling a located at /cgi-bin/test.py from a form submit.

For the better part of this afternoon I was receiving the error 'OSError: [Errno 2] No such file or directory' at the os.execve() line 1058 but now they are 'OSError: [Errno 8] Exec format error'. I've changed so much I'm not sure about the reason for the different error, but either way do_POST() isn't working for me.

$ ./demon-local.py
Serving HTTP on 0.0.0.0 port 8000
localhost - - [27/Oct/2010 21:24:39] "POST /cgi-bin/test.py HTTP/1.1" 200 -
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/http/server.py", line 1058, in run_cgi
    os.execve(scriptfile, args, os.environ)
OSError: [Errno 8] Exec format error
localhost - - [27/Oct/2010 21:24:39] CGI script exit status 0x7f00

I've run the code in pdb and can't find anything wrong with the variables scriptfile, args, and os.environ. Once I reach the os.execve line in the debugger execution seems to just hang and I have to ctrl-c a few times to kill everything.

Has anyone here had success using the built-in CGIHTTPRequestHandler?

Many thanks, Chris