[mod_python] 2.7.8: import exceptions -> os.error no longer == OSError

Gregory Bond gnb at itga.com.au
Mon Jul 21 17:48:14 EST 2003


I've done some more work and it appears that doing
	import exceptions
from inside mod_python buggers things more than somewhat for every mod_python 
script run in that process from then on.

(This was in some old and unconverted python 1.3-era code)

------------
def handler(req):
        req.send_http_header()
        req.write("before import exceptions\n")
        req.write("OSError is %d\n" % id(OSError))
        req.write("os.error is %d\n" % id(os.error))
        import exceptions
        req.write("after import exceptions\n")
        req.write("OSError is %d\n" % id(OSError))
        req.write("os.error is %d\n" % id(os.error))

        return apache.OK

------------
before import exceptions
OSError is 539788
os.error is 539788
after import exceptions
OSError is 1258380
os.error is 539788

----------
But if I run the same code (writing to stdout, rather than a req structure) 
from the command line it works OK:
----
import os, sys
req = sys.stdout

req.write("before import exceptions\n")
req.write("OSError is %d\n" % id(OSError))
req.write("os.error is %d\n" % id(os.error))
import exceptions
req.write("after import exceptions\n")
req.write("OSError is %d\n" % id(OSError))
req.write("os.error is %d\n" % id(os.error))
-----
lightning$ python t.py
before import exceptions
OSError is 900204
os.error is 900204
after import exceptions
OSError is 900204
os.error is 900204




More information about the Mod_python mailing list