]> granicus.if.org Git - python/commitdiff
Only encode Unicode objects when printing them raw.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 18 May 2003 12:56:25 +0000 (12:56 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 18 May 2003 12:56:25 +0000 (12:56 +0000)
Objects/fileobject.c

index 40ce759f5840424cd52d7c6d4eab8a9c675c8598..1cc6def62cd6fadb52d20e880265e7e9b8cdd7f1 100644 (file)
@@ -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)