traceback as string

John J. Lee jjl at
Fri Jan 16 20:53:03 CET 2004

steve at (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:

    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.  :-(


More information about the Python-list mailing list