PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead

of strict) error handler to escape surrogates
This commit is contained in:
Victor Stinner 2010-05-17 01:26:01 +00:00
parent 6baded49d0
commit 372ac5e732
3 changed files with 16 additions and 1 deletions

View file

@ -303,7 +303,9 @@ 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 {