[Python-checkins] [3.7] closes bpo-34650: Check if sched_getscheduler returns ENOSYS before declaring it supported. (GH-9236)
Benjamin Peterson
webhook-mailer at python.org
Wed Sep 12 19:00:09 EDT 2018
https://github.com/python/cpython/commit/0aef909d630ff40614cde0c58796a8bdf66c67eb
commit: 0aef909d630ff40614cde0c58796a8bdf66c67eb
branch: 3.7
author: Benjamin Peterson <benjamin at python.org>
committer: GitHub <noreply at github.com>
date: 2018年09月12日T16:00:06-07:00
summary:
[3.7] closes bpo-34650: Check if sched_getscheduler returns ENOSYS before declaring it supported. (GH-9236)
musl doesn't support the scheduler API, but declares stubs that alway return ENOSYS..
(cherry picked from commit c7042224b8a67748f125c22836862483f81a87a6)
Co-authored-by: Benjamin Peterson <benjamin at python.org>
files:
M Lib/test/test_posix.py
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index d2cb1c9840ea..11180b7278c9 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -23,6 +23,18 @@
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
'test is only meaningful on 32-bit builds')
+def _supports_sched():
+ if not hasattr(posix, 'sched_getscheduler'):
+ return False
+ try:
+ posix.sched_getscheduler(0)
+ except OSError as e:
+ if e.errno == errno.ENOSYS:
+ return False
+ return True
+
+requires_sched = unittest.skipUnless(_supports_sched(), 'requires POSIX scheduler API')
+
class PosixTester(unittest.TestCase):
def setUp(self):
@@ -1276,7 +1288,7 @@ def test_sched_priority(self):
self.assertRaises(OSError, posix.sched_get_priority_min, -23)
self.assertRaises(OSError, posix.sched_get_priority_max, -23)
- @unittest.skipUnless(hasattr(posix, 'sched_setscheduler'), "can't change scheduler")
+ @requires_sched
def test_get_and_set_scheduler_and_param(self):
possible_schedulers = [sched for name, sched in posix.__dict__.items()
if name.startswith("SCHED_")]
More information about the Python-checkins
mailing list