summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-03-24 19:25:00 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-03-24 19:25:00 (GMT)
commit8e5fd53be00001cbfa9368bd64f67cdef5d46771 (patch)
treef4182ff5d75144a6ddb1778ba23eb6beb64f1c9a /Python
parentf3f87f743efc252a0f4fa62719a2f9cf52df3f85 (diff)
downloadcpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.zip
cpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.tar.gz
cpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.tar.bz2
SF bug 480215: softspace confused in nested print
This fixes the symptom, but PRINT_ITEM has no way to know what (if anything) PyFile_WriteObject() writes unless the object being printed is a string. When the object isn't a string, this fix retains the guess that softspace should be set after PyFile_WriteObject(). We might want to say that it's the job of filelike-object write methods to leave the file's softspace in the correct state. That would probably be better -- but everyone relies on PRINT_ITEM to guess for them now.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 5e67b29..97a734c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1397,29 +1397,31 @@ eval_frame(PyFrameObject *f)
err = -1;
}
}
- if (w != NULL && PyFile_SoftSpace(w, 1))
+ if (w != NULL && PyFile_SoftSpace(w, 0))
err = PyFile_WriteString(" ", w);
if (err == 0)
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
if (err == 0) {
- /* XXX move into writeobject() ? */
+ /* XXX move into writeobject() ? */
if (PyString_Check(v)) {
char *s = PyString_AS_STRING(v);
int len = PyString_GET_SIZE(v);
- if (len > 0 &&
- isspace(Py_CHARMASK(s[len-1])) &&
- s[len-1] != ' ')
- PyFile_SoftSpace(w, 0);
+ if (len == 0 ||
+ !isspace(Py_CHARMASK(s[len-1])) ||
+ s[len-1] == ' ')
+ PyFile_SoftSpace(w, 1);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v)) {
Py_UNICODE *s = PyUnicode_AS_UNICODE(v);
int len = PyUnicode_GET_SIZE(v);
- if (len > 0 &&
- Py_UNICODE_ISSPACE(s[len-1]) &&
- s[len-1] != ' ')
- PyFile_SoftSpace(w, 0);
+ if (len == 0 ||
+ !Py_UNICODE_ISSPACE(s[len-1]) ||
+ s[len-1] == ' ')
+ PyFile_SoftSpace(w, 1);
}
+ else
+ PyFile_SoftSpace(w, 1);
#endif
}
Py_DECREF(v);