mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Merged revisions 81250-81253 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r81250 | victor.stinner | 2010-05-17 03:13:37 +0200 (lun., 17 mai 2010) | 2 lines Issue #6697: Fix a crash if code of "python -c code" contains surrogates ........ r81251 | victor.stinner | 2010-05-17 03:26:01 +0200 (lun., 17 mai 2010) | 3 lines PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead of strict) error handler to escape surrogates ........ r81252 | victor.stinner | 2010-05-17 10:58:51 +0200 (lun., 17 mai 2010) | 6 lines handle_system_exit() flushs files to warranty the output order PyObject_Print() writes into the C object stderr, whereas PySys_WriteStderr() writes into the Python object sys.stderr. Each object has its own buffer, so call sys.stderr.flush() and fflush(stderr). ........ r81253 | victor.stinner | 2010-05-17 11:33:42 +0200 (lun., 17 mai 2010) | 6 lines Fix refleak in internal_print() introduced by myself in r81251 _PyUnicode_AsDefaultEncodedString() uses a magical PyUnicode attribute to automatically destroy PyUnicode_EncodeUTF8() result when the unicode string is destroyed. ........
This commit is contained in:
parent
6763514503
commit
2e71d014ea
5 changed files with 58 additions and 6 deletions
|
@ -303,12 +303,15 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
|
|||
}
|
||||
else if (PyUnicode_Check(s)) {
|
||||
PyObject *t;
|
||||
t = _PyUnicode_AsDefaultEncodedString(s, NULL);
|
||||
t = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(s),
|
||||
PyUnicode_GET_SIZE(s),
|
||||
"backslashreplace");
|
||||
if (t == NULL)
|
||||
ret = 0;
|
||||
else {
|
||||
fwrite(PyBytes_AS_STRING(t), 1,
|
||||
PyBytes_GET_SIZE(t), fp);
|
||||
Py_DECREF(t);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue