From 2f7e50233e7a1cbe85f290ecebb30cefaf74804f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 8 Jul 2023 13:58:59 -0600 Subject: New scons_subproc_run: simplify calling in msvc Per a suggestion, do the conditional bit in MSCommon/common.py only for the past that can change, so we can have a single scons_subproc_run call - more readable. Since this didn't make 4.5, change added/deprecated markers to 4.6 Signed-off-by: Mats Wichmann --- SCons/Action.py | 4 ++-- SCons/Tool/MSCommon/common.py | 22 +++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/SCons/Action.py b/SCons/Action.py index 2e6ae16..187e929 100644 --- a/SCons/Action.py +++ b/SCons/Action.py @@ -874,7 +874,7 @@ def scons_subproc_run( Otherwise (the default) in case of an :exc:`OSError`, report the exit code in the :class:`~Subprocess.CompletedProcess` instance. - .. versionadded:: 4.5 + .. versionadded:: 4.6 """ # Figure out the execution environment to use ENV = kwargs.get('env', None) @@ -937,7 +937,7 @@ def _subproc(scons_env, cmd, error='ignore', **kw): subprocess. Adds an an error-handling argument. Adds ability to specify std{in,out,err} with "'devnull'" tag. - .. deprecated:: 4.5 + .. deprecated:: 4.6 """ # TODO: just uses subprocess.DEVNULL now, we can drop the "devnull" # string now - it is a holdover from Py2, which didn't have DEVNULL. diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index aa4b356..a3daff6 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -29,9 +29,9 @@ import copy import json import os import re -import subprocess import sys from contextlib import suppress +from subprocess import DEVNULL, PIPE from pathlib import Path import SCons.Util @@ -297,22 +297,14 @@ def get_output(vcbat, args=None, env=None): if args: debug("Calling '%s %s'", vcbat, args) - cp = SCons.Action.scons_subproc_run( - env, - '"%s" %s & set' % (vcbat, args), - stdin=subprocess.DEVNULL, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) + cmd_str = '"%s" %s & set' % (vcbat, args) else: debug("Calling '%s'", vcbat) - cp = SCons.Action.scons_subproc_run( - env, - '"%s" & set' % vcbat, - stdin=subprocess.DEVNULL, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) + cmd_str = '"%s" & set' % vcbat + + cp = SCons.Action.scons_subproc_run( + env, cmd_str, stdin=DEVNULL, stdout=PIPE, stderr=PIPE, + ) # Extra debug logic, uncomment if necessary # debug('stdout:%s', cp.stdout) -- cgit v0.12