From: Guido van Rossum Date: Tue, 22 Aug 2000 02:04:46 +0000 (+0000) Subject: Patch by Toby Dickenson: don't die when an error occurs during string X-Git-Tag: v2.0b1~315 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2823f03a56451f3187a1d85ffcef107f00f6f48e;p=thirdparty%2FPython%2Fcpython.git Patch by Toby Dickenson: don't die when an error occurs during string conversion in an exception, but instead display where %s is the type name. --- diff --git a/Lib/traceback.py b/Lib/traceback.py index d219340a80be..b733598f2584 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -166,9 +166,15 @@ def format_exception_only(etype, value): s = s + ' ' list.append('%s^\n' % s) value = msg - list.append('%s: %s\n' % (str(stype), str(value))) + list.append('%s: %s\n' % (str(stype), _some_str(value))) return list +def _some_str(value): + try: + return str(value) + except: + return '' % type(value).__name__ + def print_exc(limit=None, file=None): """This is a shorthand for 'print_exception(sys.exc_type,