Mailing List Archive

[3.11] gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (GH-117126) (#117138)
https://github.com/python/cpython/commit/0ec856157408c84f6a794b8fa0718d2c05b1fe08
commit: 0ec856157408c84f6a794b8fa0718d2c05b1fe08
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
committer: vstinner <vstinner@python.org>
date: 2024-03-21T22:37:16Z
summary:

[3.11] gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (GH-117126) (#117138)

gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (GH-117126)

On RHEL9, sched_setaffinity(0, []) does not fail.
(cherry picked from commit 50f9b0b1e0fb181875751cef951351ed007b6397)

Co-authored-by: Victor Stinner <vstinner@python.org>

files:
M Lib/test/test_posix.py

diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index c2103313d26fcf..221d25a4d62420 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1327,12 +1327,21 @@ def test_sched_getaffinity(self):
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])

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com