]> granicus.if.org Git - python/commitdiff
stdprinter_write(): mention the encoding
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 24 Mar 2015 12:40:29 +0000 (13:40 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 24 Mar 2015 12:40:29 +0000 (13:40 +0100)
Objects/fileobject.c

index 6f2e35166ba22a1f2e021c2c11074e025d2a4330..1b184100d0b9fd6cf465501e3bd40e065abfa055 100644 (file)
@@ -372,7 +372,7 @@ PyFile_NewStdPrinter(int fd)
 static PyObject *
 stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
 {
-    char *c;
+    char *str;
     Py_ssize_t n;
 
     if (self->fd < 0) {
@@ -383,10 +383,11 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
         Py_RETURN_NONE;
     }
 
-    if (!PyArg_ParseTuple(args, "s", &c))
+    /* encode Unicode to UTF-8 */
+    if (!PyArg_ParseTuple(args, "s", &str))
         return NULL;
 
-    n = _Py_write(self->fd, c, strlen(c));
+    n = _Py_write(self->fd, str, strlen(str));
     if (n == -1) {
         if (errno == EAGAIN) {
             PyErr_Clear();