Issue with exception info formatting by traceback module

Jan Decaluwe jan at jandecaluwe.com
Fri Nov 7 12:39:45 CET 2003


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 at 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("test")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
module.Error: test
>>> try:
...     raise module.Error("test")
... 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





More information about the Python-list mailing list