summaryrefslogtreecommitdiff
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index a836cb3815..234d07e5c6 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -376,7 +376,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
PyObject *bytes = NULL;
char *str;
Py_ssize_t n;
- int _errno;
+ int err;
if (self->fd < 0) {
/* fd might be invalid on Windows
@@ -403,10 +403,13 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
}
n = _Py_write(self->fd, str, n);
- _errno = errno;
+ /* save errno, it can be modified indirectly by Py_XDECREF() */
+ err = errno;
+
Py_XDECREF(bytes);
+
if (n == -1) {
- if (_errno == EAGAIN) {
+ if (err == EAGAIN) {
PyErr_Clear();
Py_RETURN_NONE;
}