Skip to content

Commit 79139b2

Browse files
committed
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.
1 parent bdc36e4 commit 79139b2

File tree

19 files changed

+10
-163
lines changed

19 files changed

+10
-163
lines changed

Include/ceval.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ PyAPI_FUNC(int) PyEval_GetRestricted(void);
4040
flag was set, else return 0. */
4141
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
4242

43-
PyAPI_FUNC(int) Py_FlushLine(void);
44-
4543
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
4644
PyAPI_FUNC(int) Py_MakePendingCalls(void);
4745

Include/fileobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ typedef struct {
1313
PyObject *f_name;
1414
PyObject *f_mode;
1515
int (*f_close)(FILE *);
16-
int f_softspace; /* Flag used by 'print' command */
1716
int f_binary; /* Flag which indicates whether the file is
1817
open in binary (1) or text (0) mode */
1918
char* f_buf; /* Allocated readahead buffer */
@@ -41,7 +40,6 @@ PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
4140
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
4241
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
4342
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
44-
PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int);
4543
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
4644
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
4745

Lib/StringIO.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def __init__(self, buf = ''):
6060
self.buflist = []
6161
self.pos = 0
6262
self.closed = False
63-
self.softspace = 0
6463

6564
def __iter__(self):
6665
return self

Lib/bsddb/dbrecio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def __init__(self, db, key, txn=None):
3939
self.len = None
4040
self.pos = 0
4141
self.closed = 0
42-
self.softspace = 0
4342

4443
def close(self):
4544
if not self.closed:

Lib/code.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
1313
"compile_command"]
1414

15-
def softspace(file, newvalue):
16-
oldvalue = 0
17-
try:
18-
oldvalue = file.softspace
19-
except AttributeError:
20-
pass
21-
try:
22-
file.softspace = newvalue
23-
except (AttributeError, TypeError):
24-
# "attribute-less object" or "read-only attributes"
25-
pass
26-
return oldvalue
27-
2815
class InteractiveInterpreter:
2916
"""Base class for InteractiveConsole.
3017
@@ -105,9 +92,6 @@ def runcode(self, code):
10592
raise
10693
except:
10794
self.showtraceback()
108-
else:
109-
if softspace(sys.stdout, 0):
110-
print()
11195

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

Lib/doctest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,10 @@ def getvalue(self):
240240
# that a trailing newline is missing.
241241
if result and not result.endswith("\n"):
242242
result += "\n"
243-
# Prevent softspace from screwing up the next test case, in
244-
# case they used print with a trailing comma in an example.
245-
if hasattr(self, "softspace"):
246-
del self.softspace
247243
return result
248244

249-
def truncate(self, size=None):
245+
def truncate(self, size=None):
250246
StringIO.truncate(self, size)
251-
if hasattr(self, "softspace"):
252-
del self.softspace
253247

254248
# Worst-case linear-time ellipsis matching.
255249
def _ellipsis_match(want, got):

Lib/idlelib/PyShell.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,6 @@ def resetoutput(self):
12231223
self.text.insert("end-1c", "\n")
12241224
self.text.mark_set("iomark", "end-1c")
12251225
self.set_line_and_column()
1226-
sys.stdout.softspace = 0
12271226

12281227
def write(self, s, tags=()):
12291228
try:
@@ -1242,7 +1241,6 @@ class PseudoFile(object):
12421241
def __init__(self, shell, tags, encoding=None):
12431242
self.shell = shell
12441243
self.tags = tags
1245-
self.softspace = 0
12461244
self.encoding = encoding
12471245

12481246
def write(self, s):

Lib/idlelib/run.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,7 @@ def cleanup_traceback(tb, exclude):
190190
tb[i] = fn, ln, nm, line
191191

192192
def flush_stdout():
193-
try:
194-
if sys.stdout.softspace:
195-
sys.stdout.softspace = 0
196-
sys.stdout.write("\n")
197-
except (AttributeError, EOFError):
198-
pass
193+
"""XXX How to do this now?"""
199194

200195
def exit():
201196
"""Exit subprocess, possibly after first deleting sys.exitfunc

Lib/socket.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class _fileobject(object):
202202
default_bufsize = 8192
203203
name = "<socket>"
204204

205-
__slots__ = ["mode", "bufsize", "softspace",
205+
__slots__ = ["mode", "bufsize",
206206
# "closed" is a property, see below
207207
"_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf",
208208
"_close"]
@@ -213,7 +213,6 @@ def __init__(self, sock, mode='rb', bufsize=-1, close=False):
213213
if bufsize < 0:
214214
bufsize = self.default_bufsize
215215
self.bufsize = bufsize
216-
self.softspace = False
217216
if bufsize == 0:
218217
self._rbufsize = 1
219218
elif bufsize == 1:

Lib/test/test_doctest.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ already:
99
We can make this fail by disabling the blank-line feature.
1010

1111
>>> if 1:
12-
... print 'a'
13-
... print
14-
... print 'b'
12+
... print('a')
13+
... print()
14+
... print('b')
1515
a
1616
<BLANKLINE>
1717
b

0 commit comments

Comments
 (0)