https://github.com/python/cpython/commit/d424344ce9e7f4a5d7ed42f660a33769e5606f9a commit: d424344ce9e7f4a5d7ed42f660a33769e5606f9a branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2025-10-08T14:26:59+02:00 summary:
[3.14] bpo-41839: Fix error checking in sched_get_priority_ functions (GH-22374) (GH-138201) (cherry picked from commit bbcb75c986c47887e6c0757e63d59cd7af544f39) Co-authored-by: Jakub KulĂk <[email protected]> files: A Misc/NEWS.d/next/Library/2020-09-23-11-54-17.bpo-41839.kU5Ywl.rst M Modules/posixmodule.c diff --git a/Misc/NEWS.d/next/Library/2020-09-23-11-54-17.bpo-41839.kU5Ywl.rst b/Misc/NEWS.d/next/Library/2020-09-23-11-54-17.bpo-41839.kU5Ywl.rst new file mode 100644 index 00000000000000..760660408100d5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-23-11-54-17.bpo-41839.kU5Ywl.rst @@ -0,0 +1,2 @@ +Allow negative priority values from :func:`os.sched_get_priority_min` and +:func:`os.sched_get_priority_max` functions. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index c6bc9c9c50488f..06a40db1078057 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8186,10 +8186,10 @@ static PyObject * os_sched_get_priority_max_impl(PyObject *module, int policy) /*[clinic end generated code: output=9e465c6e43130521 input=2097b7998eca6874]*/ { - int max; - - max = sched_get_priority_max(policy); - if (max < 0) + /* make sure that errno is cleared before the call */ + errno = 0; + int max = sched_get_priority_max(policy); + if (max == -1 && errno) return posix_error(); return PyLong_FromLong(max); } @@ -8207,8 +8207,10 @@ static PyObject * os_sched_get_priority_min_impl(PyObject *module, int policy) /*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/ { + /* make sure that errno is cleared before the call */ + errno = 0; int min = sched_get_priority_min(policy); - if (min < 0) + if (min == -1 && errno) return posix_error(); return PyLong_FromLong(min); } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
