[Tutor] What is in the traceback object

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Feb 8 19:39:03 CET 2005

On Tue, 8 Feb 2005, Ertl, John wrote:

> I have a bit of code that uses a module and I am trying to get more info
> on the error.
> I am using this bit of code:
>     try:
>         rhfill    = Ngl.contour(wks,rhisobar,rh_res)
>     except:
>         execType,value,tracebak = sys.exc_info()[:3]
>         print execType
>         print value
>         print tracebak
> In the log file I get this:
> exceptions.SystemError
> error return without exception set
> <traceback object at 0xb6cf2c84>
> How do I get the actual traceback so I can read it?

Hi John,

You can use the 'traceback' module:


Use the traceback.print_exc() function within the except block: it'll
automatically pull information from sys.exc_info() for you:

    rhfill    = Ngl.contour(wks,rhisobar,rh_res)

Best of wishes to you!

More information about the Tutor mailing list