[issue37420] os.sched_setaffinity does not handle errors during iteration.

Brandt Bucher report at bugs.python.org
Wed Jun 26 18:22:26 EDT 2019


New submission from Brandt Bucher <brandtbucher at gmail.com>:

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.

----------
components: Library (Lib)
messages: 346691
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: os.sched_setaffinity does not handle errors during iteration.
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37420>
_______________________________________


More information about the Python-bugs-list mailing list