[Idle-dev] CVS: idle run.py,1.11,1.12

Kurt B. Kaiser kbk@users.sourceforge.net
Mon, 03 Mar 2003 12:06:53 -0800


Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv25199

Modified Files:
	run.py 
Log Message:
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",


Index: run.py
===================================================================
RCS file: /cvsroot/idlefork/idle/run.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** run.py	27 Feb 2003 23:04:17 -0000	1.11
--- run.py	3 Mar 2003 20:06:48 -0000	1.12
***************
*** 74,82 ****
              exec code in self.locals
          except:
              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):'
              exclude = ("run.py", "rpc.py", "RemoteDebugger.py", "bdb.py")
              self.cleanup_traceback(tbe, exclude)
--- 74,83 ----
              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, 'Traceback (most recent call last):'
              exclude = ("run.py", "rpc.py", "RemoteDebugger.py", "bdb.py")
              self.cleanup_traceback(tbe, exclude)
***************
*** 85,88 ****
--- 86,98 ----
              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):