Kill off softspace completely (except in formatter.py which seems to have

a different feature with the same name).
The change to test_doctest.txt reduces the doctest failures to 3.
This commit is contained in:
Guido van Rossum 2007-02-09 23:20:19 +00:00
parent bdc36e4d9e
commit 79139b247b
19 changed files with 10 additions and 163 deletions

View file

@ -60,7 +60,6 @@ class StringIO:
self.buflist = []
self.pos = 0
self.closed = False
self.softspace = 0
def __iter__(self):
return self

View file

@ -39,7 +39,6 @@ class DBRecIO:
self.len = None
self.pos = 0
self.closed = 0
self.softspace = 0
def close(self):
if not self.closed:

View file

@ -12,19 +12,6 @@ from codeop import CommandCompiler, compile_command
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
"compile_command"]
def softspace(file, newvalue):
oldvalue = 0
try:
oldvalue = file.softspace
except AttributeError:
pass
try:
file.softspace = newvalue
except (AttributeError, TypeError):
# "attribute-less object" or "read-only attributes"
pass
return oldvalue
class InteractiveInterpreter:
"""Base class for InteractiveConsole.
@ -105,9 +92,6 @@ 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.

View file

@ -240,16 +240,10 @@ class _SpoofOut(StringIO):
# that a trailing newline is missing.
if result and not result.endswith("\n"):
result += "\n"
# Prevent softspace from screwing up the next test case, in
# case they used print with a trailing comma in an example.
if hasattr(self, "softspace"):
del self.softspace
return result
def truncate(self, size=None):
def truncate(self, size=None):
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
# Worst-case linear-time ellipsis matching.
def _ellipsis_match(want, got):

View file

@ -1223,7 +1223,6 @@ class PyShell(OutputWindow):
self.text.insert("end-1c", "\n")
self.text.mark_set("iomark", "end-1c")
self.set_line_and_column()
sys.stdout.softspace = 0
def write(self, s, tags=()):
try:
@ -1242,7 +1241,6 @@ class PseudoFile(object):
def __init__(self, shell, tags, encoding=None):
self.shell = shell
self.tags = tags
self.softspace = 0
self.encoding = encoding
def write(self, s):

View file

@ -190,12 +190,7 @@ def cleanup_traceback(tb, exclude):
tb[i] = fn, ln, nm, line
def flush_stdout():
try:
if sys.stdout.softspace:
sys.stdout.softspace = 0
sys.stdout.write("\n")
except (AttributeError, EOFError):
pass
"""XXX How to do this now?"""
def exit():
"""Exit subprocess, possibly after first deleting sys.exitfunc

View file

@ -202,7 +202,7 @@ class _fileobject(object):
default_bufsize = 8192
name = "<socket>"
__slots__ = ["mode", "bufsize", "softspace",
__slots__ = ["mode", "bufsize",
# "closed" is a property, see below
"_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf",
"_close"]
@ -213,7 +213,6 @@ class _fileobject(object):
if bufsize < 0:
bufsize = self.default_bufsize
self.bufsize = bufsize
self.softspace = False
if bufsize == 0:
self._rbufsize = 1
elif bufsize == 1:

View file

@ -9,9 +9,9 @@ already:
We can make this fail by disabling the blank-line feature.
>>> if 1:
... print 'a'
... print
... print 'b'
... print('a')
... print()
... print('b')
a
<BLANKLINE>
b

View file

@ -30,14 +30,10 @@ class AutoFileTests(unittest.TestCase):
def testAttributes(self):
# verify expected attributes exist
f = self.f
softspace = f.softspace
f.name # merely shouldn't blow up
f.mode # ditto
f.closed # ditto
# verify softspace is writable
f.softspace = softspace # merely shouldn't blow up
# verify the others aren't
for attr in 'name', 'mode', 'closed':
self.assertRaises((AttributeError, TypeError), setattr, f, attr, 'oops')

View file

@ -61,7 +61,6 @@ class TestPredicates(IsTestBase):
self.istest(inspect.ismodule, 'mod')
self.istest(inspect.istraceback, 'tb')
self.istest(inspect.isdatadescriptor, '__builtin__.file.closed')
self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace')
if hasattr(types, 'GetSetDescriptorType'):
self.istest(inspect.isgetsetdescriptor,
'type(tb.tb_frame).f_locals')

View file

@ -1,14 +0,0 @@
from test import test_support
import StringIO
# SF bug 480215: softspace confused in nested print
f = StringIO.StringIO()
class C:
def __str__(self):
print('a', file=f)
return 'b'
print(C(), 'c ', 'd\t', 'e', file=f)
print('f', 'g', file=f)
# In 2.2 & earlier, this printed ' a\nbc d\te\nf g\n'
test_support.vereq(f.getvalue(), 'a\nb c d\te\nf g\n')