Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50f9b0b

Browse files
authored
gh-117061: Fix test_posix.test_sched_setaffinity() on RHEL9 (#117126)
On RHEL9, sched_setaffinity(0, []) does not fail.
1 parent 0907871 commit 50f9b0b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/test_posix.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,12 +1335,21 @@ def test_sched_getaffinity(self):
13351335
def test_sched_setaffinity(self):
13361336
mask = posix.sched_getaffinity(0)
13371337
self.addCleanup(posix.sched_setaffinity, 0, list(mask))
1338+
13381339
if len(mask) > 1:
13391340
# Empty masks are forbidden
13401341
mask.pop()
13411342
posix.sched_setaffinity(0, mask)
13421343
self.assertEqual(posix.sched_getaffinity(0), mask)
1343-
self.assertRaises(OSError, posix.sched_setaffinity, 0, [])
1344+
1345+
try:
1346+
posix.sched_setaffinity(0, [])
1347+
# gh-117061: On RHEL9, sched_setaffinity(0, []) does not fail
1348+
except OSError:
1349+
# sched_setaffinity() manual page documents EINVAL error
1350+
# when the mask is empty.
1351+
pass
1352+
13441353
self.assertRaises(ValueError, posix.sched_setaffinity, 0, [-10])
13451354
self.assertRaises(ValueError, posix.sched_setaffinity, 0, map(int, "0X"))
13461355
self.assertRaises(OverflowError, posix.sched_setaffinity, 0, [1<<128])

0 commit comments

Comments
 (0)