lib: remove dead Python < 3.5 compatibility branch in script()

subprocess.run() has been available since Python 3.5 (EOL 2017).
The hasattr() guard and check_output() fallback are dead code.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
This commit is contained in:
Thomas Perrot 2026-05-05 17:47:31 +02:00 committed by Théo Lebrun
parent 83b49b313c
commit 9276d2a98b

View file

@ -28,14 +28,8 @@ CURRENT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + '/../
def script(*args, env=None):
args = (os.path.join(CURRENT_DIR, 'script.sh'),) + args
# subprocess.run was introduced in Python 3.5
# fall back to subprocess.check_output if it's not available
if hasattr(subprocess, 'run'):
p = subprocess.run(args, stdout=subprocess.PIPE, env=env)
p = p.stdout
else:
p = subprocess.check_output(args)
return p
return p.stdout
def run_cmd(*args, env=None):
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)