There was an error while loading. Please reload this page.
1 parent 56eb6b6 commit bbcb75cCopy full SHA for bbcb75c
2 files changed
Misc/NEWS.d/next/Library/2020-09-23-11-54-17.bpo-41839.kU5Ywl.rst
@@ -0,0 +1,2 @@
1
+Allow negative priority values from :func:`os.sched_get_priority_min` and
2
+:func:`os.sched_get_priority_max` functions.
Modules/posixmodule.c
@@ -8211,10 +8211,10 @@ static PyObject *
8211
os_sched_get_priority_max_impl(PyObject *module, int policy)
8212
/*[clinic end generated code: output=9e465c6e43130521 input=2097b7998eca6874]*/
8213
{
8214
- int max;
8215
-
8216
- max = sched_get_priority_max(policy);
8217
- 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)
8218
return posix_error();
8219
return PyLong_FromLong(max);
8220
}
@@ -8232,8 +8232,10 @@ static PyObject *
8232
os_sched_get_priority_min_impl(PyObject *module, int policy)
8233
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
8234
8235
8236
8237
int min = sched_get_priority_min(policy);
- if (min < 0)
8238
+ if (min == -1 && errno)
8239
8240
return PyLong_FromLong(min);
8241
0 commit comments