os.path.exists() throws Exception when the file does
not exist instead of returning 0, ONLY when MySQLdb
0.9.x is imported under mod_python. With 0.3.x works
fine (returns 0), as does without MySQLdb at all.
Test code (write into test.py)
from mod_python import apache
os.path.exists("/tmp/aaaa") output = "Worked.\n" request.content_type = "text/plain" request.send_http_header() request.write(output) return apache.OK
In httpd.conf (besides loading mod_python):
AddHandler python-program .test
If I catch the exception it says:
[Errno 2] No such file or directory: '/tmp/aaaa'
Environment is Linux RH 7.1 with
One last thing: I straced the httpd and it does this.
I'm guessing that the errors got mixed up somehow but
can't see why or how:
0xbfffe800) = -1 ENOENT (No such file or directory)
It does not do this when MySQLdb is not loaded or if
the path exists.