]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)
authorVictor Stinner <vstinner@python.org>
Thu, 21 Mar 2024 22:17:09 +0000 (23:17 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Mar 2024 22:17:09 +0000 (22:17 +0000)
On RHEL9, sched_setaffinity(0, []) does not fail.

Lib/test/test_posix.py

index 2706d5eb6d98305ac0ab022e17a5762f7dccf426..1d22869046fd124eb0b30d0d48397c9a785ea5cf 100644 (file)
@@ -1335,12 +1335,21 @@ class PosixTester(unittest.TestCase):
     def test_sched_setaffinity(self):
         mask = posix.sched_getaffinity(0)
         self.addCleanup(posix.sched_setaffinity, 0, list(mask))
+
         if len(mask) > 1:
             # Empty masks are forbidden
             mask.pop()
         posix.sched_setaffinity(0, mask)
         self.assertEqual(posix.sched_getaffinity(0), mask)
-        self.assertRaises(OSError, posix.sched_setaffinity, 0, [])
+
+        try:
+            posix.sched_setaffinity(0, [])
+            # gh-117061: On RHEL9, sched_setaffinity(0, []) does not fail
+        except OSError:
+            # sched_setaffinity() manual page documents EINVAL error
+            # when the mask is empty.
+            pass
+
         self.assertRaises(ValueError, posix.sched_setaffinity, 0, [-10])
         self.assertRaises(ValueError, posix.sched_setaffinity, 0, map(int, "0X"))
         self.assertRaises(OverflowError, posix.sched_setaffinity, 0, [1<<128])