summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/ceval.h2
-rw-r--r--Include/fileobject.h2
-rw-r--r--Lib/StringIO.py1
-rw-r--r--Lib/bsddb/dbrecio.py1
-rw-r--r--Lib/code.py16
-rw-r--r--Lib/doctest.py8
-rw-r--r--Lib/idlelib/PyShell.py2
-rw-r--r--Lib/idlelib/run.py7
-rw-r--r--Lib/socket.py3
-rw-r--r--Lib/test/test_doctest.txt6
-rw-r--r--Lib/test/test_file.py4
-rw-r--r--Lib/test/test_inspect.py1
-rw-r--r--Lib/test/test_softspace.py14
-rw-r--r--Modules/bz2module.c20
-rw-r--r--Modules/cStringIO.c11
-rw-r--r--Objects/fileobject.c44
-rw-r--r--Python/ceval.c11
-rw-r--r--Python/pythonrun.c15
-rw-r--r--Python/sysmodule.c5
19 files changed, 10 insertions, 163 deletions
diff --git a/Include/ceval.h b/Include/ceval.h
index f441197..9c77a85 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -40,8 +40,6 @@ PyAPI_FUNC(int) PyEval_GetRestricted(void);
flag was set, else return 0. */
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
-PyAPI_FUNC(int) Py_FlushLine(void);
-
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
PyAPI_FUNC(int) Py_MakePendingCalls(void);
diff --git a/Include/fileobject.h b/Include/fileobject.h
index ebbb521..ee7c4ee 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -13,7 +13,6 @@ typedef struct {
PyObject *f_name;
PyObject *f_mode;
int (*f_close)(FILE *);
- int f_softspace; /* Flag used by 'print' command */
int f_binary; /* Flag which indicates whether the file is
open in binary (1) or text (0) mode */
char* f_buf; /* Allocated readahead buffer */
@@ -41,7 +40,6 @@ PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
-PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index a6b0ea4..189d368 100644
--- a/Lib/StringIO.py
+++ b/Lib/StringIO.py
@@ -60,7 +60,6 @@ class StringIO:
self.buflist = []
self.pos = 0
self.closed = False
- self.softspace = 0
def __iter__(self):
return self
diff --git a/Lib/bsddb/dbrecio.py b/Lib/bsddb/dbrecio.py
index d439f32..975a2d9 100644
--- a/Lib/bsddb/dbrecio.py
+++ b/Lib/bsddb/dbrecio.py
@@ -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:
diff --git a/Lib/code.py b/Lib/code.py
index 8532a2e..7182777 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -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.
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 210e845..02e200d 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -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):
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index e8284d8..4c16db9 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -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):
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index fa201a8..8a0b926 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -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
diff --git a/Lib/socket.py b/Lib/socket.py
index eff47d2..2222600 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -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:
diff --git a/Lib/test/test_doctest.txt b/Lib/test/test_doctest.txt
index f8e851e..23446d1 100644
--- a/Lib/test/test_doctest.txt
+++ b/Lib/test/test_doctest.txt
@@ -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
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 91f6e76..7eb052b 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -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')
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 071e521..296e259 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -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')
diff --git a/Lib/test/test_softspace.py b/Lib/test/test_softspace.py
deleted file mode 100644
index c0b4e8f..0000000
--- a/Lib/test/test_softspace.py
+++ /dev/null
@@ -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')
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 3c6daa9..9b39442 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -102,8 +102,6 @@ typedef struct {
char* f_bufend; /* Points after last occupied position */
char* f_bufptr; /* Current buffer position */
- int f_softspace; /* Flag used by 'print' command */
-
int f_univ_newline; /* Handle any newline convention */
int f_newlinetypes; /* Types of newlines seen */
int f_skipnextlf; /* Skip next \n */
@@ -813,8 +811,6 @@ BZ2File_write(BZ2FileObject *self, PyObject *args)
goto cleanup;
}
- self->f_softspace = 0;
-
Py_BEGIN_ALLOW_THREADS
BZ2_bzWrite (&bzerror, self->fp, buf, len);
self->pos += len;
@@ -934,8 +930,6 @@ BZ2File_writelines(BZ2FileObject *self, PyObject *seq)
}
}
- self->f_softspace = 0;
-
/* Since we are releasing the global lock, the
following code may *not* execute Python code. */
Py_BEGIN_ALLOW_THREADS
@@ -1265,18 +1259,6 @@ static PyGetSetDef BZ2File_getset[] = {
/* ===================================================================== */
-/* Members of BZ2File_Type. */
-
-#undef OFF
-#define OFF(x) offsetof(BZ2FileObject, x)
-
-static PyMemberDef BZ2File_members[] = {
- {"softspace", T_INT, OFF(f_softspace), 0,
- "flag indicating that a space needs to be printed; used by print"},
- {NULL} /* Sentinel */
-};
-
-/* ===================================================================== */
/* Slot definitions for BZ2File_Type. */
static int
@@ -1501,7 +1483,7 @@ static PyTypeObject BZ2File_Type = {
(getiterfunc)BZ2File_getiter, /*tp_iter*/
(iternextfunc)BZ2File_iternext, /*tp_iternext*/
BZ2File_methods, /*tp_methods*/
- BZ2File_members, /*tp_members*/
+ 0, /*tp_members*/
BZ2File_getset, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index 3f762b0..2ed1485 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -57,7 +57,6 @@ typedef struct { /* Subtype of IOobject */
Py_ssize_t pos, string_size;
Py_ssize_t buf_size;
- int softspace;
} Oobject;
/* Declarations for objects of type StringI */
@@ -489,13 +488,6 @@ static struct PyMethodDef O_methods[] = {
{NULL, NULL} /* sentinel */
};
-static PyMemberDef O_memberlist[] = {
- {"softspace", T_INT, offsetof(Oobject, softspace), 0,
- "flag indicating that a space needs to be printed; used by print"},
- /* getattr(f, "closed") is implemented without this table */
- {NULL} /* Sentinel */
-};
-
static void
O_dealloc(Oobject *self) {
if (self->buf != NULL)
@@ -536,7 +528,7 @@ static PyTypeObject Otype = {
PyObject_SelfIter, /*tp_iter */
(iternextfunc)IO_iternext, /*tp_iternext */
O_methods, /*tp_methods */
- O_memberlist, /*tp_members */
+ 0, /*tp_members */
file_getsetlist, /*tp_getset */
};
@@ -549,7 +541,6 @@ newOobject(int size) {
return NULL;
self->pos=0;
self->string_size = 0;
- self->softspace = 0;
self->buf = (char *)malloc(size);
if (!self->buf) {
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 1e3e57c..13f64fb 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -118,7 +118,6 @@ fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode,
f->f_mode = PyString_FromString(mode);
f->f_close = close;
- f->f_softspace = 0;
f->f_binary = strchr(mode,'b') != NULL;
f->f_buf = NULL;
f->f_univ_newline = (strchr(mode, 'U') != NULL);
@@ -1523,7 +1522,6 @@ file_write(PyFileObject *f, PyObject *args)
return err_closed();
if (!PyArg_ParseTuple(args, f->f_binary ? "s#" : "t#", &s, &n))
return NULL;
- f->f_softspace = 0;
Py_BEGIN_ALLOW_THREADS
errno = 0;
n2 = fwrite(s, 1, n, f->f_fp);
@@ -1626,7 +1624,6 @@ file_writelines(PyFileObject *f, PyObject *seq)
/* Since we are releasing the global lock, the
following code may *not* execute Python code. */
Py_BEGIN_ALLOW_THREADS
- f->f_softspace = 0;
errno = 0;
for (i = 0; i < j; i++) {
line = PyList_GET_ITEM(list, i);
@@ -1786,8 +1783,6 @@ static PyMethodDef file_methods[] = {
#define OFF(x) offsetof(PyFileObject, x)
static PyMemberDef file_memberlist[] = {
- {"softspace", T_INT, OFF(f_softspace), 0,
- "flag indicating that a space needs to be printed; used by print"},
{"mode", T_OBJECT, OFF(f_mode), RO,
"file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added)"},
{"name", T_OBJECT, OFF(f_name), RO,
@@ -2094,8 +2089,7 @@ PyTypeObject PyFile_Type = {
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
- /* softspace is writable: we must supply tp_setattro */
- PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
file_doc, /* tp_doc */
@@ -2119,42 +2113,6 @@ PyTypeObject PyFile_Type = {
PyObject_Del, /* tp_free */
};
-/* Interface for the 'soft space' between print items. */
-
-int
-PyFile_SoftSpace(PyObject *f, int newflag)
-{
- long oldflag = 0;
- if (f == NULL) {
- /* Do nothing */
- }
- else if (PyFile_Check(f)) {
- oldflag = ((PyFileObject *)f)->f_softspace;
- ((PyFileObject *)f)->f_softspace = newflag;
- }
- else {
- PyObject *v;
- v = PyObject_GetAttrString(f, "softspace");
- if (v == NULL)
- PyErr_Clear();
- else {
- if (PyInt_CheckExact(v))
- oldflag = PyInt_AsLong(v);
- assert(oldflag < INT_MAX);
- Py_DECREF(v);
- }
- v = PyInt_FromLong((long)newflag);
- if (v == NULL)
- PyErr_Clear();
- else {
- if (PyObject_SetAttrString(f, "softspace", v) != 0)
- PyErr_Clear();
- Py_DECREF(v);
- }
- }
- return (int)oldflag;
-}
-
/* Interfaces to write objects/strings to file-like objects */
int
diff --git a/Python/ceval.c b/Python/ceval.c
index 7511bb6..0194687 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3349,17 +3349,6 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
return result;
}
-int
-Py_FlushLine(void)
-{
- PyObject *f = PySys_GetObject("stdout");
- if (f == NULL)
- return 0;
- if (!PyFile_SoftSpace(f, 0))
- return 0;
- return PyFile_WriteString("\n", f);
-}
-
/* External interface to call any callable object.
The arg must be a tuple or NULL. */
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 3aa1295..ec1bc42 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -795,8 +795,6 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
return -1;
}
Py_DECREF(v);
- if (Py_FlushLine())
- PyErr_Clear();
return 0;
}
@@ -883,8 +881,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
return -1;
}
Py_DECREF(v);
- if (Py_FlushLine())
- PyErr_Clear();
return 0;
}
@@ -902,8 +898,6 @@ PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
return -1;
}
Py_DECREF(v);
- if (Py_FlushLine())
- PyErr_Clear();
return 0;
}
@@ -1018,8 +1012,6 @@ handle_system_exit(void)
int exitcode = 0;
PyErr_Fetch(&exception, &value, &tb);
- if (Py_FlushLine())
- PyErr_Clear();
fflush(stdout);
if (value == NULL || value == Py_None)
goto done;
@@ -1097,8 +1089,6 @@ PyErr_PrintEx(int set_sys_last_vars)
v2 = Py_None;
Py_INCREF(v2);
}
- if (Py_FlushLine())
- PyErr_Clear();
fflush(stdout);
PySys_WriteStderr("Error in sys.excepthook:\n");
PyErr_Display(exception2, v2, tb2);
@@ -1128,8 +1118,6 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
if (f == NULL)
fprintf(stderr, "lost sys.stderr\n");
else {
- if (Py_FlushLine())
- PyErr_Clear();
fflush(stdout);
if (tb && tb != Py_None)
err = PyTraceBack_Print(tb, f);
@@ -1597,8 +1585,6 @@ call_sys_exitfunc(void)
Py_DECREF(exitfunc);
}
- if (Py_FlushLine())
- PyErr_Clear();
}
static void
@@ -1855,4 +1841,3 @@ PyRun_InteractiveLoop(FILE *f, const char *p)
#ifdef __cplusplus
}
#endif
-
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 3f2d5b7..c7d85933 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -104,8 +104,6 @@ sys_displayhook(PyObject *self, PyObject *o)
}
if (PyObject_SetAttrString(builtins, "_", Py_None) != 0)
return NULL;
- if (Py_FlushLine() != 0)
- return NULL;
outf = PySys_GetObject("stdout");
if (outf == NULL) {
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
@@ -113,8 +111,7 @@ sys_displayhook(PyObject *self, PyObject *o)
}
if (PyFile_WriteObject(o, outf, 0) != 0)
return NULL;
- PyFile_SoftSpace(outf, 1);
- if (Py_FlushLine() != 0)
+ if (PyFile_WriteString("\n", outf) != 0)
return NULL;
if (PyObject_SetAttrString(builtins, "_", o) != 0)
return NULL;