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

Skip to content

Commit ae86da9

Browse files
committed
(Merge 3.4) Issue #25182: Fix compilation on Windows
2 parents 008fc77 + 89719e1 commit ae86da9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Objects/fileobject.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
376376
PyObject *bytes = NULL;
377377
char *str;
378378
Py_ssize_t n;
379-
int _errno;
379+
int err;
380380

381381
if (self->fd < 0) {
382382
/* fd might be invalid on Windows
@@ -403,10 +403,13 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
403403
}
404404

405405
n = _Py_write(self->fd, str, n);
406-
_errno = errno;
406+
/* save errno, it can be modified indirectly by Py_XDECREF() */
407+
err = errno;
408+
407409
Py_XDECREF(bytes);
410+
408411
if (n == -1) {
409-
if (_errno == EAGAIN) {
412+
if (err == EAGAIN) {
410413
PyErr_Clear();
411414
Py_RETURN_NONE;
412415
}

0 commit comments

Comments
 (0)