]> granicus.if.org Git - python/commitdiff
bug [ 1172785 ] doctest.script_from_examples() result sometimes un-exec-able
authorGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:22:31 +0000 (22:22 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 26 Jun 2005 22:22:31 +0000 (22:22 +0000)
Lib/doctest.py

index e3d4d79930a93b7c4243b63257e72f88ded97db6..5b00ec5c6c1af58fff5d5b4debeb12e68d1f4ae3 100644 (file)
@@ -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.