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

Skip to content

Commit 454bd3a

Browse files
committed
stdprinter_write(): mention the encoding
1 parent 3b06dfb commit 454bd3a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Objects/fileobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ PyFile_NewStdPrinter(int fd)
372372
static PyObject *
373373
stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
374374
{
375-
char *c;
375+
char *str;
376376
Py_ssize_t n;
377377

378378
if (self->fd < 0) {
@@ -383,10 +383,11 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
383383
Py_RETURN_NONE;
384384
}
385385

386-
if (!PyArg_ParseTuple(args, "s", &c))
386+
/* encode Unicode to UTF-8 */
387+
if (!PyArg_ParseTuple(args, "s", &str))
387388
return NULL;
388389

389-
n = _Py_write(self->fd, c, strlen(c));
390+
n = _Py_write(self->fd, str, strlen(str));
390391
if (n == -1) {
391392
if (errno == EAGAIN) {
392393
PyErr_Clear();

0 commit comments

Comments
 (0)