This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sys.last_type missing
Type: Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Trundle, benjamin.peterson, brtzsnr
Priority: normal Keywords:

Created on 2009-03-23 10:01 by brtzsnr, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg84002 - (view) Author: Alexandru V. Mosoi (brtzsnr) Date: 2009-03-23 10:01
`sys.last_type' is missing and thus, traceback.print_last() is not working.

$ python
Python 2.6.1 (r261:67515, Dec  7 2008, 18:56:39) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import sys
>>> try: raise Exception('asdf')
... except: print sys.last_type
... 
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
AttributeError: 'module' object has no attribute 'last_type'

>>> import traceback
>>> try: raise Exception('asdf')
... except: traceback.print_last()
... 
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
AttributeError: 'module' object has no attribute 'last_type'
msg84031 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-23 20:48
Fixed in r70552.
msg84037 - (view) Author: Andreas Stührk (Trundle) * Date: 2009-03-23 21:18
Is the fix really correct? The documentation clearly states about
`sys.last_type`: "These three variables are not always defined; they are set
when an exception is not handled and the interpreter prints an error
message and a stack traceback." And there is already
`traceback.print_exc()`, which is a shorthand for
"print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit,
file)". So, in my opinion, the previous behaviour was intended behaviour,
and the OP needs to use `traceback.print_exc()`.
msg84038 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-23 21:24
Trundle, you are correct. Reverted in r697553.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49793
2009-03-23 21:24:02benjamin.petersonsetresolution: fixed -> not a bug
messages: + msg84038
2009-03-23 21:18:52Trundlesetnosy: + Trundle
messages: + msg84037
2009-03-23 20:48:13benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg84031

resolution: fixed
2009-03-23 10:01:46brtzsnrcreate