Better traceback information?
Olivier Dagenais
olivierS.dagenaisP at canadaA.comM
Sun Oct 22 14:35:08 EDT 2000
In my app, I exec code and class definitions that I just fished out from a
database. The problem is, if an exception is thrown from inside one of
these definitions, the traceback usually gives me '<string>' as the
offending "file". Is it possible for me to give exec a more descriptive
value? It gets really hard when one constructor creates another object
(which throws) and the traceback shows:
File "<string>", line xx, in __init__
(...)
File "<string>", line yy, in __init__
(...)
I'd prefer something like:
File "<class Animal>", line xx, in __init__
(...)
File "<class Cow>", line yy, in __init__
(...)
execfile (and a StringIO object) is out of the question, as it takes a file
name (not a handle to an open file) and that's the only thing I can think
of. Ideas??
For bonus points, I'd also like to know if I can add an offset to the line
number spewed out.
Thanks!
--
----------------------------------------------------------------------
Olivier A. Dagenais - Software Architect and Developer
"Someone called 'Type your name here' is impersonating me on the
internet and is posting exactly the same things I am posting!"
More information about the Python-list
mailing list