]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
doctest doesn't handle intentional SyntaxError exceptions gracefully,
authorTim Peters <tim.peters@gmail.com>
Sun, 24 Jun 2001 06:46:58 +0000 (06:46 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 24 Jun 2001 06:46:58 +0000 (06:46 +0000)
because it picks up the first line of traceback.format_exception_only()
instead of the last line.  Pick up the last line instead!

Lib/doctest.py

index 270e3087e752a5a613887f5898c021311855bebb..08879dd9810899cd64df44b77b92912d1cd9d0d9 100644 (file)
@@ -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