]> granicus.if.org Git - python/commitdiff
complain when there's no last exception
authorBenjamin Peterson <benjamin@python.org>
Mon, 23 Mar 2009 21:25:15 +0000 (21:25 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 23 Mar 2009 21:25:15 +0000 (21:25 +0000)
Lib/traceback.py

index 3d877ee1502b38281c76d30c373993602e40f62f..b06fcea79618529e17bd8a8e83a8ed54b3e6d26d 100644 (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,