473,657 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting tracebacks from traceback objects

Hello,

For a GUI app I've tried resetting sys.excepthook to my own
exceptionhandle r 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******@digit altorque.ca>
http://www.digitaltorque.ca
http://opag.ca python -c 'import this'
Jabber: ms******@digita ltorque.ca

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

iD8DBQFCu026KGq Cc1vIvggRAusVAJ 9dhQtIRM3RFABDN TXbe8ol5NP2TQCg mItT
cavao1soJ0Nrkw2 3q4nbMys=
=H7vZ
-----END PGP SIGNATURE-----

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

For a GUI app I've tried resetting sys.excepthook to my own
exceptionhandle r 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_exceptio n() 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
1847
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 statements at different places. Is there a way to "turn on" traceback writing to std.err (that also shows up at the screen)? Thanks Mike
0
1203
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 call last): File "/usr/lib/python2.4/atexit.py", line 22, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.4/threading.py", line 636, in __exitfunc self._Thread__delete()
7
1782
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 python online docs one gets the idea that simply returning is OK - but I'm not sure. Is it ok to do a sys.ext()? Use 'return' or just let them run out with no 'return' ???
0
1072
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 thought try: Main.Main() except Exception, err_o: print err_o.__class__.__name__, '//', err_o, '//', err_o.args that was suggested to me however it doesn't catch the errors i made in
1
1417
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, and the full pathnames to my python source files are pushing 150 characters. I either need a laptop with a wider screen, or younger eyes so I can read a smaller font :-)
8
3316
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 to get done better. I notice on stack traces and tracebacks, an exec or execfile command appears as a stack entry -- probably as it should since it creates a new environment. However the frame information for exec or execfile looks like this:...
0
1074
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. Until now, these tools didn't pass a utility vs pain-to-use threshold. Now I've created a tool I believe to have passed that threshold, which I call "binding annotated exception tracebacks". In short, this tool adds text showing relevant local...
5
1330
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 deferred callable, a callable that will be called at some point in the future (possibly in a different thread) and whose result or raised exception is to be stored as an attribute. This will be available by calling the result() method, which returns...
4
9824
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, by definition, contradictory. I disagree.) Consequently, I'd like to suppress Python's tracebacks if an error does occur, replacing it with a more friendly error message. I'm doing something like this:
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.