mirror of
https://github.com/python/cpython.git
synced 2025-09-04 07:51:13 +00:00
Only encode Unicode objects when printing them raw.
This commit is contained in:
parent
9a3a9f7791
commit
415da6e0b2
1 changed files with 2 additions and 1 deletions
|
@ -2064,7 +2064,8 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef Py_USING_UNICODE
|
#ifdef Py_USING_UNICODE
|
||||||
if (PyUnicode_Check(v) && enc != Py_None) {
|
if ((flags & Py_PRINT_RAW) &&
|
||||||
|
PyUnicode_Check(v) && enc != Py_None) {
|
||||||
char *cenc = PyString_AS_STRING(enc);
|
char *cenc = PyString_AS_STRING(enc);
|
||||||
value = PyUnicode_AsEncodedString(v, cenc, "strict");
|
value = PyUnicode_AsEncodedString(v, cenc, "strict");
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue