469,945 Members | 1,828 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Re: Unusual Exception Behaviour

mk
http://linux.byexamples.com/archives...eption-traceba
ck-into-log-file/
>if __name__=="__main__":
try:
main()
except:
print "Trigger Exception, traceback info forward to log file."
traceback.print_exc(file=open("errlog.txt","a"))
sys.exit(1)

I've just given this solution a shot but I still seem to get the same
result, it suddenly starts dumping the log data to the command line, and
nothing gets printed in error.txt apart from the keyboard interrupt from
when I kill the application.
That's seriously weird. What's your Python version and platform? On my
Windows and Linux machines, with more recent Python versions the above
trick works flawlessly.

Check your environment, namely PYTHON* variables. There may be something
causing this behaviour. Unset them.

Check the first line of your scripts. If you're calling wrong Python
interpreter (there may be more than one in the system for some reason),
this may cause it.

You could also try setting up PYTHONINSPECT environment variable or run
the python interpreter with -i option before program filename, which
drops you into an interactive shell upon exception or termination of a
program.
For some reason the exceptions don't seem to be raised properly so obviously
aren't being caught at this higher level.

So confusing.
This behavior is seriously unusual for Python. Maybe you have some old /
buggy version?


Jul 17 '08 #1
0 958

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.