traceback as string
John J. Lee
jjl at pobox.com
Fri Jan 16 14:53:03 EST 2004
steve at ferg.org (Stephen Ferg) writes:
[...]
> try:
> main1()
> except Exception, e:
> print exception_format(e)
[...]
Just a semi-random warning for anybody as stupid as me: "finally:"
blocks do not handle exceptions, so don't expect things like using the
traceback module to work there:
try:
main1()
finally:
print exception_format(e) # WRONG
I spent a long time tracing through the Python source code trying to
track down a non-existent bug in a C extension, thanks to this
misconception. :-(
John
More information about the Python-list
mailing list