This is related to bpo-37417: os.sched_setaffinity doesn't properly handle errors that arise during iteration of the mask argument:
Python 3.9.0a0 (heads/master:d52a83a, Jun 26 2019, 15:13:41)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> bad_iter = map(int, "0X")
>>> os.sched_setaffinity(0, bad_iter)
ValueError: invalid literal for int() with base 10: 'X'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: <built-in function sched_setaffinity> returned a result with an error set
It looks like this bug is also present on all versions of Python 3. I've attached a patch with a fix and a regression test. |