From: Tim Peters Date: Sun, 24 Jun 2001 06:46:58 +0000 (+0000) Subject: doctest doesn't handle intentional SyntaxError exceptions gracefully, X-Git-Tag: v2.2a3~1441 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08bba953eacd60a011224ff633189f11291427b4;p=thirdparty%2FPython%2Fcpython.git doctest doesn't handle intentional SyntaxError exceptions gracefully, because it picks up the first line of traceback.format_exception_only() instead of the last line. Pick up the last line instead! --- diff --git a/Lib/doctest.py b/Lib/doctest.py index 270e3087e752..08879dd98108 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -501,7 +501,7 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name): # the traceback isn't necessary. want = want.split('\n')[-2] + '\n' exc_type, exc_val, exc_tb = sys.exc_info() - got = traceback.format_exception_only(exc_type, exc_val)[0] + got = traceback.format_exception_only(exc_type, exc_val)[-1] state = OK else: # unexpected exception