diff Lib/code.py @ 15847:679d50705e06 legacy-trunk

SF Patch #103227 by mwh: make code.py appreciate softspace
author Guido van Rossum <guido@python.org>
date Sat, 13 Jan 2001 22:10:41 +0000
parents 5c65e676f299
children 71b19d36aafa
line wrap: on
line diff
--- a/Lib/code.py	Sat Jan 13 22:06:05 2001 +0000
+++ b/Lib/code.py	Sat Jan 13 22:10:41 2001 +0000
@@ -10,6 +10,17 @@
 import traceback
 from codeop import compile_command
 
+def softspace(file, newvalue):
+    oldvalue = 0
+    try:
+        oldvalue = file.softspace
+    except AttributeError:
+        pass
+    try:
+        file.softspace = newvalue
+    except TypeError: # "attribute-less object" or "read-only attributes"
+        pass
+    return oldvalue
 
 class InteractiveInterpreter:
     """Base class for InteractiveConsole.
@@ -90,6 +101,9 @@
             raise
         except:
             self.showtraceback()
+        else:
+            if softspace(sys.stdout, 0):
+                print
 
     def showsyntaxerror(self, filename=None):
         """Display the syntax error that just occurred.