How to extract complete file path from traceback info

K

Kenneth McDonald

I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.

Thanks,
Ken McDonald
 
P

Peter Hansen

Kenneth said:
I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.

Searching the source for the traceback module, I saw that it
calls code in the linecache module which apparently has to
do a manual search down the sys.path to find the files that
are imported... that probably means (a) there is no other
way to do it, (b) there's example code for you in linecache.py,
and (c) it might have some troubles with the new zip-file
based imports etc... (not that that would be a particular
problem in your case, but it could confuse things).

-Peter
 
T

Thomas Guettler

Am Fri, 18 Jun 2004 21:31:03 +0000 schrieb Kenneth McDonald:
I have a need to customize the output of Python error tracebacks,
and to that end I've implemented my own sys.excepthook function.
However, one remaining problem that I'm having is the information
passed to this function doesn't seem to have the _full_ path name
of the file in which the exception occurred. I need this because
the output is being parsed by an editor (jEdit) which uses this
information to set up links to errors origins in the source
code.

Is there an easy way to get this info somehow? (I haven't been
able to find it.) I can think of some 'solutions' I'd prefer
not to attempt unless I have to.

Hi Kenneth,

AFAIK, the module cgitb does this. Take a look at it.

HTH,
Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top