mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead
of strict) error handler to escape surrogates
This commit is contained in:
parent
6baded49d0
commit
372ac5e732
3 changed files with 16 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue