AttributeError: last_traceback

Guido van Rossum guido at
Fri Aug 31 23:28:47 CEST 2001

Curtis Jensen <cjensen at> writes:

> I have a section of code similar to this:
>     try:
>       exec(  <SOMETHING> )
>     except:
>       print traceback.print_exc()
> This is so exceptions don't bring down my program.  And some errors, I
> can ignor.  However, some errors I need to debug.  For the errors I want
> to debug, I'd like to uses ""  however, I always get
> "AttributeError: last_traceback" with ""  Understandably, this
> is because noe exception was loged, because I caught it.  
> Is there a way I can catch exceptions and still use

  import sys
      exec <SOMETHING>
      sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
      print traceback.print_exc()

--Guido van Rossum (home page:

More information about the Python-list mailing list