diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-04-28 19:43:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 19:43:43 (GMT) |
commit | 35e6bbe16a859b42efca4592b435695a530f0717 (patch) | |
tree | 5a298b113bb1899e91583866b41eb9c337c0857e /src/engine/SCons/Action.py | |
parent | 44c7b81e1a47ff5d4439740b1e929ea723ee1f18 (diff) | |
parent | 4ecdcf07580b1bfcd03f7886b6ab9256ee825175 (diff) | |
download | SCons-35e6bbe16a859b42efca4592b435695a530f0717.zip SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.gz SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.bz2 |
Merge pull request #3345 from mwichmann/py38warns4-tests
[wip] Py38warns4 tests
Diffstat (limited to 'src/engine/SCons/Action.py')
-rw-r--r-- | src/engine/SCons/Action.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 1257309..d1ab362 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -211,7 +211,7 @@ def _object_contents(obj): def _code_contents(code, docstring=None): - """Return the signature contents of a code object. + r"""Return the signature contents of a code object. By providing direct access to the code object of the function, Python makes this extremely easy. Hooray! @@ -767,16 +767,22 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): it'll have to be tweaked to get the full desired functionality. one special arg (so far?), 'error', to tell what to do with exceptions. """ - # allow std{in,out,err} to be "'devnull'" - io = kw.get('stdin') - if is_String(io) and io == 'devnull': - kw['stdin'] = open(os.devnull) - io = kw.get('stdout') - if is_String(io) and io == 'devnull': - kw['stdout'] = open(os.devnull, 'w') - io = kw.get('stderr') - if is_String(io) and io == 'devnull': - kw['stderr'] = open(os.devnull, 'w') + # allow std{in,out,err} to be "'devnull'". This is like + # subprocess.DEVNULL, which does not exist for Py2. Use the + # subprocess one if possible. + # Clean this up when Py2 support is dropped + try: + from subprocess import DEVNULL + except ImportError: + DEVNULL = None + + for stream in 'stdin', 'stdout', 'stderr': + io = kw.get(stream) + if is_String(io) and io == 'devnull': + if DEVNULL: + kw[stream] = DEVNULL + else: + kw[stream] = open(os.devnull, "r+") # Figure out what shell environment to use ENV = kw.get('env', None) |