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: AttributeError in traceback.print_last()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: complex, r.david.murray
Priority: low Keywords:

Created on 2009-06-18 11:37 by complex, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg89499 - (view) Author: Viktor Ferenczi (complex) Date: 2009-06-18 11:37
Python 2.5.4, Windows MSI installer, WinXP SP2, 32 bit:

Try the following code: (test script attached)

import traceback

try:
    someundefinedsymbol
except:
    traceback.print_last()

It will raise the following exception:

Traceback (most recent call last):
  File "bug.py", line 6, in <module>
    traceback.print_last()
  File "D:\Python25\lib\traceback.py", line 246, in print_last
    print_exception(sys.last_type, sys.last_value, sys.last_traceback,
AttributeError: 'module' object has no attribute 'last_type'
msg89500 - (view) Author: Viktor Ferenczi (complex) Date: 2009-06-18 11:41
From the manual of the sys module:

"""
last_type 
last_value
last_traceback

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.
"""

So the AttributeError is normal in this case.

Changed the bug type to "behavior", since a more meaningful error
message than AttributeError would be very useful in this case.

Thanks.
msg89503 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-06-18 13:04
In 2.7/3.1 this message is a ValueError saying "no last traceback".
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50556
2009-06-18 13:04:23r.david.murraysetstatus: open -> closed
priority: low


nosy: + r.david.murray
messages: + msg89503
resolution: out of date
stage: resolved
2009-06-18 11:41:48complexsettype: crash -> behavior
messages: + msg89500
2009-06-18 11:37:25complexcreate