diff options
Diffstat (limited to 'Objects/fileobject.c')
| -rw-r--r-- | Objects/fileobject.c | 19 | 
1 files changed, 5 insertions, 14 deletions
| diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 1a93a6dd6b..234d07e5c6 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -402,26 +402,17 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)          }      } -    Py_BEGIN_ALLOW_THREADS -    errno = 0; -#ifdef MS_WINDOWS -    if (n > INT_MAX) -        n = INT_MAX; -    n = write(self->fd, str, (int)n); -#else -    n = write(self->fd, str, n); -#endif +    n = _Py_write(self->fd, str, n);      /* save errno, it can be modified indirectly by Py_XDECREF() */      err = errno; -    Py_END_ALLOW_THREADS      Py_XDECREF(bytes); -    if (n < 0) { -        if (err == EAGAIN) +    if (n == -1) { +        if (err == EAGAIN) { +            PyErr_Clear();              Py_RETURN_NONE; -        errno = err; -        PyErr_SetFromErrno(PyExc_IOError); +        }          return NULL;      } | 
