closes bpo-37420: Handle errors during iteration in os.sched_setaffinity. (GH-14414)
(cherry picked from commit 45a30af109f69a81576b87ea775863ba12d55316)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 70b1536..4301e87 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6416,6 +6416,9 @@
}
CPU_SET_S(cpu, setsize, cpu_set);
}
+ if (PyErr_Occurred()) {
+ goto error;
+ }
Py_CLEAR(iterator);
if (sched_setaffinity(pid, setsize, cpu_set)) {