Issue with exception info formatting by traceback module

Discussion in 'Python' started by Jan Decaluwe, Nov 7, 2003.

  1. Jan Decaluwe

    Jan Decaluwe Guest

    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("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
     
    Jan Decaluwe, Nov 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenneth McDonald
    Replies:
    2
    Views:
    379
    Thomas Guettler
    Jun 21, 2004
  2. Duncan Booth

    Using Python traceback info from C/C++.

    Duncan Booth, Jul 12, 2004, in forum: Python
    Replies:
    1
    Views:
    1,982
    Jeff Holle
    Jul 12, 2004
  3. Joe Peterson
    Replies:
    4
    Views:
    314
    Joe Peterson
    Jul 5, 2005
  4. R. Bernstein
    Replies:
    8
    Views:
    411
    R. Bernstein
    Jan 16, 2006
  5. Jack Bates
    Replies:
    0
    Views:
    289
    Jack Bates
    May 2, 2011
Loading...

Share This Page