summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-06-26 22:22:31 (GMT)
committerGeorg Brandl <georg@python.org>2005-06-26 22:22:31 (GMT)
commit1f149642c9940662f45004a0bf5f5b05034aa67b (patch)
treef9a8b940584096d137d0c5da63e08f8b8f24ada1
parent2f210b6bca65f3e32b49d876c44722c52c30b780 (diff)
downloadcpython-1f149642c9940662f45004a0bf5f5b05034aa67b.zip
cpython-1f149642c9940662f45004a0bf5f5b05034aa67b.tar.gz
cpython-1f149642c9940662f45004a0bf5f5b05034aa67b.tar.bz2
bug [ 1172785 ] doctest.script_from_examples() result sometimes un-exec-able
-rw-r--r--Lib/doctest.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index e3d4d79..5b00ec5 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.