diff options
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index 1b8d4e1..b2a5492 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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 { |