summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-27 13:15:45 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-27 13:15:45 (GMT)
commitc7acf2a106caacc11397e35afe054816fd6181fa (patch)
tree3eb0a826eabd8d7968198399eb28b5efb9902286
parentcebfa70a794ba3d4aeda681b3164123d934d1c28 (diff)
downloadcpython-c7acf2a106caacc11397e35afe054816fd6181fa.zip
cpython-c7acf2a106caacc11397e35afe054816fd6181fa.tar.gz
cpython-c7acf2a106caacc11397e35afe054816fd6181fa.tar.bz2
handle class exceptions
-rw-r--r--Lib/compileall.py5
-rw-r--r--Lib/lib-old/tb.py5
-rw-r--r--Lib/tb.py5
-rw-r--r--Lib/traceback.py19
4 files changed, 25 insertions, 9 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index cd02851..3120284 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -30,7 +30,10 @@ def compile_dir(dir, maxlevels = 10):
print '\n[interrupt]'
break
except:
- print 'Sorry:', sys.exc_type + ':',
+ if type(sys.exc_type) == type(''):
+ exc_type_name = sys.exc_type
+ else: exc_type_name = sys.exc_type.__name__
+ print 'Sorry:', exc_type_name + ':',
print sys.exc_value
elif maxlevels > 0 and \
name != os.curdir and name != os.pardir and \
diff --git a/Lib/lib-old/tb.py b/Lib/lib-old/tb.py
index 6b9cd9a..0442ba8 100644
--- a/Lib/lib-old/tb.py
+++ b/Lib/lib-old/tb.py
@@ -74,7 +74,10 @@ def browserexec(tb, cmd):
exec(cmd+'\n', globals, locals)
except:
print '*** Exception:',
- print sys.exc_type,
+ if type(sys.exc_type) == type(''):
+ print sys.exc_type,
+ else:
+ print sys.exc_type.__name__,
if sys.exc_value <> None:
print ':', sys.exc_value,
print
diff --git a/Lib/tb.py b/Lib/tb.py
index 6b9cd9a..0442ba8 100644
--- a/Lib/tb.py
+++ b/Lib/tb.py
@@ -74,7 +74,10 @@ def browserexec(tb, cmd):
exec(cmd+'\n', globals, locals)
except:
print '*** Exception:',
- print sys.exc_type,
+ if type(sys.exc_type) == type(''):
+ print sys.exc_type,
+ else:
+ print sys.exc_type.__name__,
if sys.exc_value <> None:
print ':', sys.exc_value,
print
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 1eec209..5ab3ec6b 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -3,6 +3,7 @@
import linecache
import string
import sys
+import types
def print_tb(tb, limit = None):
if limit is None:
@@ -41,23 +42,29 @@ def extract_tb(tb, limit = None):
n = n+1
return list
-def print_exception(type, value, tb, limit = None):
+def print_exception(etype, value, tb, limit = None):
if tb:
print 'Traceback (innermost last):'
print_tb(tb, limit)
+ if type(etype) == types.ClassType:
+ stype = etype.__name__
+ else:
+ stype = etype
if value is None:
- print type
+ print stype
else:
- if type is SyntaxError:
+ if etype is SyntaxError:
try:
msg, (filename, lineno, offset, line) = value
except:
pass
else:
if not filename: filename = "<string>"
- print ' File "%s", line %d' % (filename, lineno)
+ print ' File "%s", line %d' % \
+ (filename, lineno)
i = 0
- while i < len(line) and line[i] in string.whitespace:
+ while i < len(line) and \
+ line[i] in string.whitespace:
i = i+1
s = ' '
print s + string.strip(line)
@@ -68,7 +75,7 @@ def print_exception(type, value, tb, limit = None):
s = s + ' '
print s + '^'
value = msg
- print '%s: %s' % (type, value)
+ print '%s: %s' % (stype, value)
def print_exc(limit = None):
print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,