From: Georg Brandl Date: Sun, 26 Jun 2005 22:22:31 +0000 (+0000) Subject: bug [ 1172785 ] doctest.script_from_examples() result sometimes un-exec-able X-Git-Tag: v2.5a0~1642 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f149642c9940662f45004a0bf5f5b05034aa67b;p=python bug [ 1172785 ] doctest.script_from_examples() result sometimes un-exec-able --- diff --git a/Lib/doctest.py b/Lib/doctest.py index e3d4d79930..5b00ec5c6c 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -2498,7 +2498,8 @@ def script_from_examples(s): while output and output[0] == '#': output.pop(0) # Combine the output, and return it. - return '\n'.join(output) + # Add a courtesy newline to prevent exec from choking (see bug #1172785) + return '\n'.join(output) + '\n' def testsource(module, name): """Extract the test sources from a doctest docstring as a script.