mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Fix for bug #480188: printing unicode objects
This commit is contained in:
parent
4586d2c91c
commit
0c4d8d05a8
3 changed files with 39 additions and 3 deletions
|
@ -6,3 +6,16 @@ Testing builtin unicode()... done.
|
||||||
Testing builtin codecs... done.
|
Testing builtin codecs... done.
|
||||||
Testing standard mapping codecs... 0-127... 128-255... done.
|
Testing standard mapping codecs... 0-127... 128-255... done.
|
||||||
Testing Unicode string concatenation... done.
|
Testing Unicode string concatenation... done.
|
||||||
|
Testing Unicode printing... abc
|
||||||
|
abc def
|
||||||
|
abc def
|
||||||
|
abc def
|
||||||
|
abc
|
||||||
|
|
||||||
|
abc
|
||||||
|
abc
|
||||||
|
def
|
||||||
|
|
||||||
|
def
|
||||||
|
|
||||||
|
done.
|
||||||
|
|
|
@ -644,3 +644,16 @@ verify((u"abc" "def") == u"abcdef")
|
||||||
verify((u"abc" u"def" "ghi") == u"abcdefghi")
|
verify((u"abc" u"def" "ghi") == u"abcdefghi")
|
||||||
verify(("abc" "def" u"ghi") == u"abcdefghi")
|
verify(("abc" "def" u"ghi") == u"abcdefghi")
|
||||||
print 'done.'
|
print 'done.'
|
||||||
|
|
||||||
|
print 'Testing Unicode printing...',
|
||||||
|
print u'abc'
|
||||||
|
print u'abc', u'def'
|
||||||
|
print u'abc', 'def'
|
||||||
|
print 'abc', u'def'
|
||||||
|
print u'abc\n'
|
||||||
|
print u'abc\n',
|
||||||
|
print u'abc\n',
|
||||||
|
print u'def\n'
|
||||||
|
print u'def\n'
|
||||||
|
print 'done.'
|
||||||
|
|
||||||
|
|
|
@ -1349,15 +1349,25 @@ eval_frame(PyFrameObject *f)
|
||||||
err = PyFile_WriteString(" ", w);
|
err = PyFile_WriteString(" ", w);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
|
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
|
||||||
if (err == 0 && PyString_Check(v)) {
|
if (err == 0) {
|
||||||
/* XXX move into writeobject() ? */
|
/* XXX move into writeobject() ? */
|
||||||
char *s = PyString_AsString(v);
|
if (PyString_Check(v)) {
|
||||||
int len = PyString_Size(v);
|
char *s = PyString_AS_STRING(v);
|
||||||
|
int len = PyString_GET_SIZE(v);
|
||||||
if (len > 0 &&
|
if (len > 0 &&
|
||||||
isspace(Py_CHARMASK(s[len-1])) &&
|
isspace(Py_CHARMASK(s[len-1])) &&
|
||||||
s[len-1] != ' ')
|
s[len-1] != ' ')
|
||||||
PyFile_SoftSpace(w, 0);
|
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);
|
Py_DECREF(v);
|
||||||
Py_XDECREF(stream);
|
Py_XDECREF(stream);
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue