summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-29 23:22:12 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-29 23:22:12 (GMT)
commitf15d15964b6ac3e5ff71894707fbcff48bec45b2 (patch)
treee0fccf5a3756b03f3f0b2a265c65a175ffe61f09
parentc90ad2103eb9aca14b7a910cbcdcd7b570f690ab (diff)
downloadcpython-f15d15964b6ac3e5ff71894707fbcff48bec45b2.zip
cpython-f15d15964b6ac3e5ff71894707fbcff48bec45b2.tar.gz
cpython-f15d15964b6ac3e5ff71894707fbcff48bec45b2.tar.bz2
Use sys.exc_info() where needed.
-rw-r--r--Lib/bdb.py4
-rwxr-xr-xLib/cgi.py3
-rw-r--r--Lib/lib-old/tb.py11
-rw-r--r--Lib/mhlib.py2
-rw-r--r--Lib/ni.py3
-rw-r--r--Lib/ni1.py3
-rwxr-xr-xLib/pdb.py27
-rw-r--r--Lib/tb.py11
-rw-r--r--Lib/types.py6
9 files changed, 38 insertions, 32 deletions
diff --git a/Lib/bdb.py b/Lib/bdb.py
index cab80a2..e4b6d39 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -148,7 +148,7 @@ class Bdb: # Basic Debugger
try:
1 + ''
except:
- frame = sys.exc_traceback.tb_frame.f_back
+ frame = sys.exc_info()[2].tb_frame.f_back
self.reset()
while frame:
frame.f_trace = self.trace_dispatch
@@ -168,7 +168,7 @@ class Bdb: # Basic Debugger
try:
1 + '' # raise an exception
except:
- frame = sys.exc_traceback.tb_frame.f_back
+ frame = sys.exc_info()[2].tb_frame.f_back
while frame and frame is not self.botframe:
del frame.f_trace
frame = frame.f_back
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 388e440..fb3076c 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -1210,7 +1210,7 @@ def test(environ=os.environ):
def print_exception(type=None, value=None, tb=None, limit=None):
if type is None:
- type, value, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
+ type, value, tb = sys.exc_info()
import traceback
print
print "<H3>Traceback (innermost last):</H3>"
@@ -1220,6 +1220,7 @@ def print_exception(type=None, value=None, tb=None, limit=None):
escape(string.join(list[:-1], "")),
escape(list[-1]),
)
+ del tb
def print_environ(environ=os.environ):
"""Dump the shell environment as HTML."""
diff --git a/Lib/lib-old/tb.py b/Lib/lib-old/tb.py
index 641e8af..5c592ce 100644
--- a/Lib/lib-old/tb.py
+++ b/Lib/lib-old/tb.py
@@ -74,13 +74,14 @@ def browserexec(tb, cmd):
try:
exec cmd+'\n' in globals, locals
except:
+ t, v = sys.exc_info()[:2]
print '*** Exception:',
- if type(sys.exc_type) == type(''):
- print sys.exc_type,
+ if type(t) == type(''):
+ print t,
else:
- print sys.exc_type.__name__,
- if sys.exc_value <> None:
- print ':', sys.exc_value,
+ print t.__name__,
+ if v <> None:
+ print ':', v,
print
print 'Type help to get help.'
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index 838b2f7..a78b2c7 100644
--- a/Lib/mhlib.py
+++ b/Lib/mhlib.py
@@ -379,7 +379,7 @@ class Folder:
if not seqs.has_key(head):
if not msg:
msg = "bad message list %s" % seq
- raise Error, msg, sys.exc_traceback
+ raise Error, msg, sys.exc_info()[2]
msgs = seqs[head]
if not msgs:
raise Error, "sequence %s empty" % head
diff --git a/Lib/ni.py b/Lib/ni.py
index fa24d30..95c9b59 100644
--- a/Lib/ni.py
+++ b/Lib/ni.py
@@ -412,8 +412,7 @@ def test():
try:
testproper()
except:
- sys.last_type, sys.last_value, sys.last_traceback = (
- sys.exc_type, sys.exc_value, sys.exc_traceback)
+ sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
print
print sys.last_type, ':', sys.last_value
print
diff --git a/Lib/ni1.py b/Lib/ni1.py
index fa24d30..95c9b59 100644
--- a/Lib/ni1.py
+++ b/Lib/ni1.py
@@ -412,8 +412,7 @@ def test():
try:
testproper()
except:
- sys.last_type, sys.last_value, sys.last_traceback = (
- sys.exc_type, sys.exc_value, sys.exc_traceback)
+ sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
print
print sys.last_type, ':', sys.last_value
print
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 99e6191..0dc15a2 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -80,10 +80,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
code = compile(line + '\n', '<stdin>', 'single')
exec code in globals, locals
except:
- if type(sys.exc_type) == type(''):
- exc_type_name = sys.exc_type
- else: exc_type_name = sys.exc_type.__name__
- print '***', exc_type_name + ':', sys.exc_value
+ t, v = sys.exc_info()[:2]
+ if type(t) == type(''):
+ exc_type_name = t
+ else: exc_type_name = t.__name__
+ print '***', exc_type_name + ':', v
# Command definitions, called by cmdloop()
# The argument is the remaining string on the command line
@@ -219,10 +220,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
value = eval(arg, self.curframe.f_globals, \
self.curframe.f_locals)
except:
- if type(sys.exc_type) == type(''):
- exc_type_name = sys.exc_type
- else: exc_type_name = sys.exc_type.__name__
- print '***', exc_type_name + ':', `sys.exc_value`
+ t, v = sys.exc_info()[:2]
+ if type(t) == type(''):
+ exc_type_name = t
+ else: exc_type_name = t.__name__
+ print '***', exc_type_name + ':', `v`
return
print `value`
@@ -277,10 +279,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
value = eval(arg, self.curframe.f_globals, \
self.curframe.f_locals)
except:
- if type(sys.exc_type) == type(''):
- exc_type_name = sys.exc_type
- else: exc_type_name = sys.exc_type.__name__
- print '***', exc_type_name + ':', `sys.exc_value`
+ t, v = sys.exc_info()[:2]
+ if type(t) == type(''):
+ exc_type_name = t
+ else: exc_type_name = t.__name__
+ print '***', exc_type_name + ':', `v`
return
code = None
# Is it a function?
diff --git a/Lib/tb.py b/Lib/tb.py
index 641e8af..5c592ce 100644
--- a/Lib/tb.py
+++ b/Lib/tb.py
@@ -74,13 +74,14 @@ def browserexec(tb, cmd):
try:
exec cmd+'\n' in globals, locals
except:
+ t, v = sys.exc_info()[:2]
print '*** Exception:',
- if type(sys.exc_type) == type(''):
- print sys.exc_type,
+ if type(t) == type(''):
+ print t,
else:
- print sys.exc_type.__name__,
- if sys.exc_value <> None:
- print ':', sys.exc_value,
+ print t.__name__,
+ if v <> None:
+ print ':', v,
print
print 'Type help to get help.'
diff --git a/Lib/types.py b/Lib/types.py
index 5254ebc..aeac304 100644
--- a/Lib/types.py
+++ b/Lib/types.py
@@ -51,10 +51,12 @@ try:
raise TypeError
except TypeError:
try:
- TracebackType = type(sys.exc_traceback)
- FrameType = type(sys.exc_traceback.tb_frame)
+ tb = sys.exc_info()[2]
+ TracebackType = type(tb)
+ FrameType = type(tb.tb_frame)
except:
pass
+ tb = None; del tb
SliceType = type(slice(0))
EllipsisType = type(Ellipsis)