mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-116448: Handle errors correctly in os_waitid_impl
in posixmodule
(GH-116449) (#116451)
gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` (GH-116449)
(cherry picked from commit 882fcede83
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
1e75fe1468
commit
cbd94fdb6c
1 changed files with 19 additions and 9 deletions
|
@ -9400,15 +9400,25 @@ os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options)
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
PyStructSequence_SET_ITEM(result, 0, PyLong_FromPid(si.si_pid));
|
int pos = 0;
|
||||||
PyStructSequence_SET_ITEM(result, 1, _PyLong_FromUid(si.si_uid));
|
|
||||||
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong((long)(si.si_signo)));
|
#define SET_RESULT(CALL) \
|
||||||
PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong((long)(si.si_status)));
|
do { \
|
||||||
PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong((long)(si.si_code)));
|
PyObject *item = (CALL); \
|
||||||
if (PyErr_Occurred()) {
|
if (item == NULL) { \
|
||||||
Py_DECREF(result);
|
Py_DECREF(result); \
|
||||||
return NULL;
|
return NULL; \
|
||||||
}
|
} \
|
||||||
|
PyStructSequence_SET_ITEM(result, pos++, item); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
SET_RESULT(PyLong_FromPid(si.si_pid));
|
||||||
|
SET_RESULT(_PyLong_FromUid(si.si_uid));
|
||||||
|
SET_RESULT(PyLong_FromLong((long)(si.si_signo)));
|
||||||
|
SET_RESULT(PyLong_FromLong((long)(si.si_status)));
|
||||||
|
SET_RESULT(PyLong_FromLong((long)(si.si_code)));
|
||||||
|
|
||||||
|
#undef SET_RESULT
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue