diff options
author | Guido van Rossum <guido@python.org> | 2007-02-09 23:20:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-02-09 23:20:19 (GMT) |
commit | 79139b247b0bc0bc1b1a12932140bbd4bc188df7 (patch) | |
tree | fef7ef79dcb4e2a1ca033e725b1c2d802e9447d2 /Objects | |
parent | bdc36e4d9e754dd00f17f67a943217a1829c75b3 (diff) | |
download | cpython-79139b247b0bc0bc1b1a12932140bbd4bc188df7.zip cpython-79139b247b0bc0bc1b1a12932140bbd4bc188df7.tar.gz cpython-79139b247b0bc0bc1b1a12932140bbd4bc188df7.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 44 |
1 files changed, 1 insertions, 43 deletions
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 |