mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
SF Patch #103227 by mwh: make code.py appreciate softspace
This commit is contained in:
parent
03df3b3bc1
commit
4ec59c75e3
1 changed files with 14 additions and 0 deletions
14
Lib/code.py
14
Lib/code.py
|
@ -10,6 +10,17 @@ import string
|
|||
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 @@ class InteractiveInterpreter:
|
|||
raise
|
||||
except:
|
||||
self.showtraceback()
|
||||
else:
|
||||
if softspace(sys.stdout, 0):
|
||||
print
|
||||
|
||||
def showsyntaxerror(self, filename=None):
|
||||
"""Display the syntax error that just occurred.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue