473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1088

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mk | last post by:
Robert Rawlins wrote: Sure. I'm a little confused as to how I can modify that Remember, Google is your friend, here's the crux of the method without the fancy schmancy sugar coating:
0
by: Robert Rawlins | last post by:
That's seriously weird. What's your Python version and platform? On my Thanks for that MK. I'm using Debian with Python 2.5 from the stable apt repository, installed but a couple of days ago....
0
by: Robert Rawlins | last post by:
>That's seriously weird. What's your Python version and platform? On my repository, installed but a couple of days ago. I'll be sure to look into those other elements you suggested also. I'm not...
3
by: Robert Rawlins | last post by:
Hi Mk, Yeah it's got me a little bemused to be honest, I've tried playing around with configuration options this morning and not been able to achieve anything that works properly. I'll keep...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.