[Python-checkins] CVS: python/dist/src/Python ceval.c,2.307,2.308
Tim Peters
tim_one@users.sourceforge.net
Sun, 24 Mar 2002 11:25:02 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv28901/python/Python
Modified Files:
ceval.c
Log Message:
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.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.307
retrieving revision 2.308
diff -C2 -d -r2.307 -r2.308
*** ceval.c 22 Mar 2002 23:53:16 -0000 2.307
--- ceval.c 24 Mar 2002 19:25:00 -0000 2.308
***************
*** 1398,1414 ****
}
}
! if (w != NULL && PyFile_SoftSpace(w, 1))
err = PyFile_WriteString(" ", w);
if (err == 0)
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
if (err == 0) {
! /* 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);
}
#ifdef Py_USING_UNICODE
--- 1398,1414 ----
}
}
! 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() ? */
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, 1);
}
#ifdef Py_USING_UNICODE
***************
*** 1416,1424 ****
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);
}
#endif
}
--- 1416,1426 ----
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, 1);
}
+ else
+ PyFile_SoftSpace(w, 1);
#endif
}