summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-18 16:46:36 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-18 16:46:36 (GMT)
commit2deb73a961a97387811a2402f82aadb70d3f576a (patch)
tree6e10a46e13c89e034082caeea1d0262935e192ac /Lib
parent4994657c5fd97dbb1570a7a6cf837c85297d7b21 (diff)
downloadcpython-2deb73a961a97387811a2402f82aadb70d3f576a.zip
cpython-2deb73a961a97387811a2402f82aadb70d3f576a.tar.gz
cpython-2deb73a961a97387811a2402f82aadb70d3f576a.tar.bz2
Use sys.exc_info() instead of sys.exc_{type,value,traceback}.
Also corrected a typo in format_stack (t should've been f).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/traceback.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 7488f15..968a9cb 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -128,8 +128,11 @@ def format_exception_only(etype, value):
def print_exc(limit=None, file=None):
if not file:
file = sys.stderr
- print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,
- limit, file)
+ try:
+ etype, value, tb = sys.exc_info()
+ print_exception(etype, value, tb, limit, file)
+ finally:
+ etype = value = tb = None
def print_last(limit=None, file=None):
if not file:
@@ -143,8 +146,7 @@ def print_stack(f=None, limit=None, file=None):
try:
raise ZeroDivisionError
except ZeroDivisionError:
- tb = sys.exc_traceback
- f = tb.tb_frame.f_back
+ f = sys.exc_info()[2].tb_frame.f_back
print_list(extract_stack(f, limit), file)
def format_stack(f=None, limit=None):
@@ -152,17 +154,15 @@ def format_stack(f=None, limit=None):
try:
raise ZeroDivisionError
except ZeroDivisionError:
- tb = sys.exc_traceback
- f = tb.tb_frame.f_back
- return format_list(extract_stack(t, limit))
+ f = sys.exc_info()[2].tb_frame.f_back
+ return format_list(extract_stack(f, limit))
def extract_stack(f=None, limit = None):
if f is None:
try:
raise ZeroDivisionError
except ZeroDivisionError:
- tb = sys.exc_traceback
- f = tb.tb_frame.f_back
+ f = sys.exc_info()[2].tb_frame.f_back
if limit is None:
if hasattr(sys, 'tracebacklimit'):
limit = sys.tracebacklimit