gh-107913: Fix possible losses of OSError error codes (GH-107930)

Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
This commit is contained in:
Serhiy Storchaka 2023-08-27 00:35:06 +03:00 committed by GitHub
parent e407cea193
commit 2b15536fa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 129 additions and 75 deletions

View file

@ -3069,8 +3069,8 @@ _curses_getwin(PyObject *module, PyObject *file)
}
datalen = PyBytes_GET_SIZE(data);
if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
Py_DECREF(data);
PyErr_SetFromErrno(PyExc_OSError);
Py_DECREF(data);
goto error;
}
Py_DECREF(data);