sys.excepthook, getting traceback values

Discussion in 'Python' started by Josh Close, Jul 23, 2004.

  1. Josh Close

    Josh Close Guest

    When sys.excepthook is called, type, value and traceback are passed
    into it. How do I get the values of traceback?

    I've tried printing it, but I get the memory location. I'm gussing
    there are some methods to use on it.

    >From what I can tell the traceback that's passed in works differently

    from the module traceback.

    I just need to get the traceback to log it. I can use type and value,
    but that doesn't print what line the error occurred.

    -Josh
     
    Josh Close, Jul 23, 2004
    #1
    1. Advertising

  2. Josh Close

    Larry Bates Guest

    Here is what I use:

    import traceback
    #
    # Get traceback lines
    #
    tblines=traceback.format_exception(type, value, tb)

    Basically this is what prints in an uncaught exception.
    You can then print, write to file, etc.

    HTH,
    Larry Bates
    Syscon, Inc.

    "Josh Close" <> wrote in message
    news:...
    > When sys.excepthook is called, type, value and traceback are passed
    > into it. How do I get the values of traceback?
    >
    > I've tried printing it, but I get the memory location. I'm gussing
    > there are some methods to use on it.
    >
    > >From what I can tell the traceback that's passed in works differently

    > from the module traceback.
    >
    > I just need to get the traceback to log it. I can use type and value,
    > but that doesn't print what line the error occurred.
    >
    > -Josh
     
    Larry Bates, Jul 23, 2004
    #2
    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. Follower
    Replies:
    1
    Views:
    3,058
    Jeremy Fincher
    Oct 27, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    573
    Tim Peters
    Oct 30, 2003
  3. Jonathan  Ellis

    Re: sys.excepthook and threads

    Jonathan Ellis, Oct 5, 2004, in forum: Python
    Replies:
    0
    Views:
    453
    Jonathan Ellis
    Oct 5, 2004
  4. Lunchtimemama

    Problem overriding sys.excepthook

    Lunchtimemama, Jan 1, 2006, in forum: Python
    Replies:
    6
    Views:
    402
    Lunchtimemama
    Jan 3, 2006
  5. Jai
    Replies:
    1
    Views:
    176
    Neil Cerutti
    Nov 19, 2013
Loading...

Share This Page