Skip to content

Commit 4ec59c7

Browse files
committed
SF Patch #103227 by mwh: make code.py appreciate softspace
1 parent 03df3b3 commit 4ec59c7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/code.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
import traceback
1111
from codeop import compile_command
1212

13+
def softspace(file, newvalue):
14+
oldvalue = 0
15+
try:
16+
oldvalue = file.softspace
17+
except AttributeError:
18+
pass
19+
try:
20+
file.softspace = newvalue
21+
except TypeError: # "attribute-less object" or "read-only attributes"
22+
pass
23+
return oldvalue
1324

1425
class InteractiveInterpreter:
1526
"""Base class for InteractiveConsole.
@@ -90,6 +101,9 @@ def runcode(self, code):
90101
raise
91102
except:
92103
self.showtraceback()
104+
else:
105+
if softspace(sys.stdout, 0):
106+
print
93107

94108
def showsyntaxerror(self, filename=None):
95109
"""Display the syntax error that just occurred.

0 commit comments

Comments
 (0)