469,903 Members | 2,126 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

getting tracebacks from traceback objects

Hello,

For a GUI app I've tried resetting sys.excepthook to my own
exceptionhandler bound method, which accepts a type, value and traceback
object.

Now, the traceback module has print_exc and format_exc methods that are
supposed to take a traceback object and return a formatted traceback
like the default output. Unfortunately I keep getting 'None' out of
them. Not sure why.

Happens here too.
def handler(type, value, tb): ... traceback.print_exc(tb)
... import traceback
import sys
sys.excepthook = handler
assert(False)

None

Pretty sure this worked in 1.5.2. Am I doing something wrong here?

I want format_exe especially, since I don't want to print to stdout, I
want to provide the traceback in a popup dialog.

Thanks,
Mike

--
Michael P. Soulier <ms******@digitaltorque.ca>
http://www.digitaltorque.ca
http://opag.ca python -c 'import this'
Jabber: ms******@digitaltorque.ca

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFCu026KGqCc1vIvggRAusVAJ9dhQtIRM3RFABDNTXbe8 ol5NP2TQCgmItT
cavao1soJ0Nrkw23q4nbMys=
=H7vZ
-----END PGP SIGNATURE-----

Jul 19 '05 #1
1 2058
Michael P. Soulier wrote:
Hello,

For a GUI app I've tried resetting sys.excepthook to my own
exceptionhandler bound method, which accepts a type, value and traceback
object.

Now, the traceback module has print_exc and format_exc methods that are
supposed to take a traceback object and return a formatted traceback
like the default output. Unfortunately I keep getting 'None' out of
them. Not sure why.
You are misreading the docs. print_exc() and format_exc() take args of [limit[, file]] not a traceback.
I want format_exe especially, since I don't want to print to stdout, I
want to provide the traceback in a popup dialog.


Use format_exception() or pass a StringIO object as the file parameter to print_exc().

Kent
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike Müller | last post: by
reply views Thread by Maxwell Hammer | last post: by
reply views Thread by Timothy Smith | last post: by
1 post views Thread by Roy Smith | last post: by
reply views Thread by Nathan | last post: by
5 posts views Thread by George Sakkis | last post: by
4 posts views Thread by Steven D'Aprano | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.