complain when there's no last exception

This commit is contained in:
Benjamin Peterson 2009-03-23 21:25:15 +00:00
parent 3e6c335ae0
commit 797eaf305a
1 changed files with 2 additions and 0 deletions

View File

@ -241,6 +241,8 @@ def format_exc(limit=None):
def print_last(limit=None, file=None):
"""This is a shorthand for 'print_exception(sys.last_type,
sys.last_value, sys.last_traceback, limit, file)'."""
if not hasattr(sys, "last_type"):
raise ValueError("no last exception")
if file is None:
file = sys.stderr
print_exception(sys.last_type, sys.last_value, sys.last_traceback,