summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Action.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
commitc2d9eaeffe9d77d8d5087fb21a3256fde32047d4 (patch)
tree144aeb4702d258b0cfaf99cffb9f21e94b026459 /src/engine/SCons/Action.py
parent6ca68f29862bc7cbe5428426eee600cb1f3c05c1 (diff)
parentefdf3fdbcd2f7654cb8d1209a8b040914437bacd (diff)
Update upstream source from tag 'upstream/3.1.0'
Update to upstream version '3.1.0' with Debian dir e69b7671114411c368722827d87d86b44ed7cd40
Diffstat (limited to 'src/engine/SCons/Action.py')
-rw-r--r--src/engine/SCons/Action.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index f1ca2cf..b541256 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -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 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Action.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import pickle
@@ -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!
@@ -534,7 +534,7 @@ class ActionBase(object):
result = self.get_presig(target, source, env)
if not isinstance(result,(bytes, bytearray)):
- result = bytearray("",'utf-8').join([ SCons.Util.to_bytes(r) for r in result ])
+ result = bytearray(result, 'utf-8')
else:
# Make a copy and put in bytearray, without this the contents returned by get_presig
# can be changed by the logic below, appending with each call and causing very
@@ -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)
@@ -802,7 +808,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
kw['env'] = new_env
try:
- pobj = 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
@@ -820,9 +826,10 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
finally:
# clean up open file handles stored in parent's kw
for k, v in kw.items():
- if hasattr(v, 'close'):
+ if inspect.ismethod(getattr(v, 'close', None)):
v.close()
- return pobj
+
+ return pobj
class CommandAction(_ActionAction):
@@ -1091,7 +1098,7 @@ class LazyAction(CommandGeneratorAction, CommandAction):
def get_parent_class(self, env):
c = env.get(self.var)
- if is_String(c) and not '\n' in c:
+ if is_String(c) and '\n' not in c:
return CommandAction
return CommandGeneratorAction