1 https://github.com/python/cpython/pull/22374
3 From b415ba00a73229ad102d590226decea014be11cc Mon Sep 17 00:00:00 2001
4 From: Jakub Kulik <kulikjak@gmail.com>
5 Date: Fri, 6 Nov 2020 14:58:33 +0100
6 Subject: [PATCH 4/4] Make the error checking more robust
9 Modules/posixmodule.c | 12 +++++++++---
10 1 file changed, 9 insertions(+), 3 deletions(-)
12 diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
13 index 82edeb39022b4..f8651d7f02bb4 100644
14 --- a/Modules/posixmodule.c
15 +++ b/Modules/posixmodule.c
16 @@ -6347,8 +6347,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
20 + /* make sure that errno is cleared before the call */
22 max = sched_get_priority_max(policy);
24 + if (max == -1 && errno == EINVAL)
26 return PyLong_FromLong(max);
28 @@ -6366,8 +6368,12 @@ static PyObject *
29 os_sched_get_priority_min_impl(PyObject *module, int policy)
30 /*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
32 - int min = sched_get_priority_min(policy);
36 + /* make sure that errno is cleared before the call */
38 + min = sched_get_priority_min(policy);
39 + if (min == -1 && errno == EINVAL)
41 return PyLong_FromLong(min);