473,770 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with exception info formatting by traceback module

Hi:

There is a difference between exception info formatting by
the interpreter versus the traceback module. For example,
say we define an exception Error in file module.py:

[jand@localhost jand]$ python
Python 2.3 (#1, Sep 12 2003, 15:05:00)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
import module
raise module.Error("t est") Traceback (most recent call last):
File "<stdin>", line 1, in ?
module.Error: test try: .... raise module.Error("t est")
.... except:
.... import traceback
.... print traceback.print _exc()
....
Traceback (most recent call last):
File "<stdin>", line 2, in ?
Error: test
None


In the second case, only the basename of the error is reported,
which is less clear. This is relevant because the unittest framework
uses the traceback module for exception reporting.

I believe the traceback module should be modified to mimic the
interpreter's behavior.

Regards, jan

--
Jan Decaluwe - Resources bvba - http://jandecaluwe.com
Losbergenlaan 16, B-3010 Leuven, Belgium
Bored with EDA the way it is? Check this:
http://jandecaluwe.com/Tools/MyHDL/Overview.html

Jul 18 '05 #1
0 1366

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1636
by: Jon Perez | last post by:
(sorry for the duplicate post, just wanted to make the subject line clearer) How do you set up pdb such that you will automatically get dropped into its prompt if an unanticipated exception occurs in a script you are using? ASPN Python cookbook gives you the following method which you can add to your script and hook into sys.excepthook. But is there a way to do it without adding stuff to your
3
1845
by: sj | last post by:
Suppose the following are part of a long file and executed: logging.basicConfig(stream = sys.stderr, level=logging.INFO) logging.info("%d %d", 1, 2, 3) # buggy Python prints the traceback of the error as follows: Traceback (most recent call last): File ".../local/lib/python2.4/logging/__init__.py", line 706, in emit msg = self.format(record)
5
1595
by: Saizan | last post by:
In an event-driven application i'd like to keep the program alive regardless of any exceptions raised by the handlers, but still be able to debug them by reading the appropriate TraceBack from stderr. I can put something like: try: self.call_handler(handler,*args) except Exception, e: print e print e.args
1
1263
by: Bryan | last post by:
hi, i would like to save an exception and reraise it at a later time. something similar to this: exception = None def foo():     try:
5
1935
by: NeBlackCat (lists) | last post by:
Hello everybody - my first post! And it may be the most monumentally stupid question ever asked, but I just can't see an answer after several hours experimenting, searching and reading. It's simply this - how can a function determine whether or not it's being called in handling of an exception (ie. there is an "active" exception, and somewhere upstream on the stack there is an except: block statement)? Depending on what you read,...
2
1967
by: Sami | last post by:
Hello, In the Python book that I am using to learn the language it says that the traceback.print_exc() can be used to stop exception propagation and make the program keep running. Here is a simple piece of code that I typed in to test this fact: --------------------------------------------------------------------------- import sys
5
3797
by: Thomas Guettler | last post by:
Hi, How can you get the traceback of the inner exception? try: try: import does_not_exit except ImportError: raise Exception("something wrong") except:
0
792
by: mk | last post by:
Robert Rawlins wrote: Sure. I'm a little confused as to how I can modify that Remember, Google is your friend, here's the crux of the method without the fancy schmancy sugar coating:
3
2041
by: Robert Rawlins | last post by:
Hi Mk, Yeah it's got me a little bemused to be honest, I've tried playing around with configuration options this morning and not been able to achieve anything that works properly. I'll keep testing though and as soon as I have a root cause to the problem I'll be sure to let the list know.
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9904
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...
1
7456
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
6710
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.