Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 415da6e

Browse files
committed
Only encode Unicode objects when printing them raw.
1 parent 9a3a9f7 commit 415da6e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Objects/fileobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,8 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
20642064
return -1;
20652065
}
20662066
#ifdef Py_USING_UNICODE
2067-
if (PyUnicode_Check(v) && enc != Py_None) {
2067+
if ((flags & Py_PRINT_RAW) &&
2068+
PyUnicode_Check(v) && enc != Py_None) {
20682069
char *cenc = PyString_AS_STRING(enc);
20692070
value = PyUnicode_AsEncodedString(v, cenc, "strict");
20702071
if (value == NULL)

0 commit comments

Comments
 (0)