summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Action.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Action.py')
-rw-r--r--src/engine/SCons/Action.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 97040a4..f1ca2cf 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -77,7 +77,7 @@ way for wrapping up the functions.
"""
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -98,7 +98,7 @@ way for wrapping up the functions.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Action.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Action.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import os
import pickle
@@ -107,6 +107,7 @@ import sys
import subprocess
import itertools
import inspect
+from collections import OrderedDict
import SCons.Debug
from SCons.Debug import logInstanceCreation
@@ -115,8 +116,7 @@ import SCons.Util
import SCons.Subst
# we use these a lot, so try to optimize them
-is_String = SCons.Util.is_String
-is_List = SCons.Util.is_List
+from SCons.Util import is_String, is_List
class _null(object):
pass
@@ -258,8 +258,7 @@ def _code_contents(code, docstring=None):
# function. Note that we have to call _object_contents on each
# constants because the code object of nested functions can
# show-up among the constants.
-
- z = [_object_contents(cc) for cc in code.co_consts[1:]]
+ z = [_object_contents(cc) for cc in code.co_consts if cc != docstring]
contents.extend(b',(')
contents.extend(bytearray(',', 'utf-8').join(z))
contents.extend(b')')
@@ -803,7 +802,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
kw['env'] = new_env
try:
- return subprocess.Popen(cmd, **kw)
+ pobj = subprocess.Popen(cmd, **kw)
except EnvironmentError as e:
if error == 'raise': raise
# return a dummy Popen instance that only returns error
@@ -817,7 +816,13 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
def readline(self): return ''
def __iter__(self): return iter(())
stdout = stderr = f()
- return dummyPopen(e)
+ pobj = dummyPopen(e)
+ finally:
+ # clean up open file handles stored in parent's kw
+ for k, v in kw.items():
+ if hasattr(v, 'close'):
+ v.close()
+ return pobj
class CommandAction(_ActionAction):
@@ -837,8 +842,8 @@ class CommandAction(_ActionAction):
_ActionAction.__init__(self, **kw)
if is_List(cmd):
if [c for c in cmd if is_List(c)]:
- raise TypeError("CommandAction should be given only " \
- "a single command")
+ raise TypeError("CommandAction should be given only "
+ "a single command")
self.cmd_list = cmd
def __str__(self):
@@ -1289,7 +1294,7 @@ class ListAction(ActionBase):
return result
def get_varlist(self, target, source, env, executor=None):
- result = SCons.Util.OrderedDict()
+ result = OrderedDict()
for act in self.list:
for var in act.get_varlist(target, source, env, executor):
result[var] = True