From 415da6e0b22924e5b4c080cfdbbaed655d6684c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 18 May 2003 12:56:25 +0000 Subject: [PATCH] Only encode Unicode objects when printing them raw. --- Objects/fileobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 40ce759f584..1cc6def62cd 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -2064,7 +2064,8 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) return -1; } #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); value = PyUnicode_AsEncodedString(v, cenc, "strict"); if (value == NULL)