summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-03-03 20:06:48 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-03-03 20:06:48 (GMT)
commitb6aff15183cf21fe829d3395c901817739c49839 (patch)
tree20a628dabc299ab11c1dfee9837c1b023e063c75 /Lib/idlelib
parent2fe07fda2d2d6f88e99a83ed7c625e80489a6f4d (diff)
downloadcpython-b6aff15183cf21fe829d3395c901817739c49839.zip
cpython-b6aff15183cf21fe829d3395c901817739c49839.tar.gz
cpython-b6aff15183cf21fe829d3395c901817739c49839.tar.bz2
SF 695861
Eliminate extra blank line in shell output. Caused by stdout not being flushed upon completion of subprocess' Executive.runcode() when user code ends by outputting an unterminated line, e.g. print "test",
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/run.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index e2594dd..6ab8044 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -73,17 +73,27 @@ class Executive:
try:
exec code in self.locals
except:
+ self.flush_stdout()
efile = sys.stderr
typ, val, tb = info = sys.exc_info()
sys.last_type, sys.last_value, sys.last_traceback = info
tbe = traceback.extract_tb(tb)
- print >>efile, '\nTraceback (most recent call last):'
+ print >>efile, 'Traceback (most recent call last):'
exclude = ("run.py", "rpc.py", "RemoteDebugger.py", "bdb.py")
self.cleanup_traceback(tbe, exclude)
traceback.print_list(tbe, file=efile)
lines = traceback.format_exception_only(typ, val)
for line in lines:
print>>efile, line,
+ self.flush_stdout()
+
+ def flush_stdout(self):
+ try:
+ if sys.stdout.softspace:
+ sys.stdout.softspace = 0
+ sys.stdout.write("\n")
+ except AttributeError:
+ pass
def cleanup_traceback(self, tb, exclude):
"Remove excluded traces from beginning/end of tb; get cached lines"