From: Benjamin Peterson Date: Mon, 23 Mar 2009 21:25:15 +0000 (+0000) Subject: complain when there's no last exception X-Git-Tag: v2.7a1~1814 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=797eaf305a1e4cbaf2041e9b28b125398e2c235a;p=python complain when there's no last exception --- diff --git a/Lib/traceback.py b/Lib/traceback.py index 3d877ee150..b06fcea796 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -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,