]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport bug [ 1172785 ] doctest.script_from_examples() result sometimes un-exec...
authorGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:23:44 +0000 (22:23 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:23:44 +0000 (22:23 +0000)
Lib/doctest.py

index f621b62fe241e64c3e609d0aa49c9f370275a938..18125f6b4b4f5b014778bff6fa900e58f67865a6 100644 (file)
@@ -2494,7 +2494,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.