Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a59018c commit 89719e1Copy full SHA for 89719e1
1 file changed
Objects/fileobject.c
@@ -376,7 +376,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
376
PyObject *bytes = NULL;
377
char *str;
378
Py_ssize_t n;
379
- int _errno;
+ int err;
380
381
if (self->fd < 0) {
382
/* fd might be invalid on Windows
@@ -411,13 +411,16 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
411
#else
412
n = write(self->fd, str, n);
413
#endif
414
- _errno = errno;
+ /* save errno, it can be modified indirectly by Py_XDECREF() */
415
+ err = errno;
416
Py_END_ALLOW_THREADS
417
+
418
Py_XDECREF(bytes);
419
420
if (n < 0) {
- if (_errno == EAGAIN)
421
+ if (err == EAGAIN)
422
Py_RETURN_NONE;
423
+ errno = err;
424
PyErr_SetFromErrno(PyExc_IOError);
425
return NULL;
426
}
0 commit comments