473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2178
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Müller | last post by:
When I embed Python into C there is no traceback message on the screen after an uncaught exception. Using sys.exc_info() I can print may own traceback but I would need to insert try except...
0
by: Maxwell Hammer | last post by:
Hope someone can help with a problem I'm having. A python program I wrote terminates with the following traceback. *** start traceback *** Error in atexit._run_exitfuncs: Traceback (most recent...
7
by: Maxwell Hammer | last post by:
Hi all, This is related to an earlier post 'Help with thread related tracebacks'...for which I have had no feedback yet :-( How should a thread complete i.e. how should it exit? Reading the...
0
by: Timothy Smith | last post by:
iw ant to use a singel try except statment with my main app loop in the middle and catch all tracebacks and email them to myself as a bug report. however it seems a little more tricky then i...
1
by: Roy Smith | last post by:
Is there any way to make the traceback printer built into the interpreter elide all the directories in pathnames (like strip_dirs() does for the profiler)? I'm working in a deep directory tree,...
8
by: R. Bernstein | last post by:
In doing the extension to the python debugger which I have here: http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827 I came across one little thing that it would be nice...
0
by: Nathan | last post by:
Hi folks! Throughout my python development career, I've occasionally made various developer tools to show more information about assertions or exceptions with less hassle to the programmer. ...
5
by: George Sakkis | last post by:
I'm reading the docs on sys.exc_info() but I can't tell for sure whether I'm using it safely to get a snapshot of an exception and reraise it later. The use case is a class which acts like a...
4
by: Steven D'Aprano | last post by:
I'm writing a command-line application that is meant to be relatively user friendly to non-technical users. (Some wags might like to say that "user friendly" and "command-line application" are,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.