[Python-checkins] CVS: python/dist/src/Python ceval.c,2.289,2.290
M.-A. Lemburg
lemburg@users.sourceforge.net
Tue, 20 Nov 2001 07:17:28 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv15987/Python
Modified Files:
ceval.c
Log Message:
Fix for bug #480188: printing unicode objects
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.289
retrieving revision 2.290
diff -C2 -d -r2.289 -r2.290
*** ceval.c 2001/11/08 08:34:43 2.289
--- ceval.c 2001/11/20 15:17:25 2.290
***************
*** 1350,1361 ****
if (err == 0)
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
! if (err == 0 && PyString_Check(v)) {
/* XXX move into writeobject() ? */
! char *s = PyString_AsString(v);
! int len = PyString_Size(v);
if (len > 0 &&
isspace(Py_CHARMASK(s[len-1])) &&
s[len-1] != ' ')
PyFile_SoftSpace(w, 0);
}
Py_DECREF(v);
--- 1350,1371 ----
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);
+ }
+ 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);
+ }
}
Py_DECREF(v);