gyp: more decode stdout on Python 3

PR-URL: https://github.com/nodejs/node-gyp/pull/1894
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit is contained in:
cclauss 2019-09-26 11:29:03 +02:00 committed by Rod Vagg
parent d90d9c5426
commit 67dec1496a
No known key found for this signature in database
GPG key ID: C273792F7D83545D
2 changed files with 13 additions and 3 deletions

View file

@ -8,13 +8,17 @@ import os
import sys
import subprocess
PY3 = bytes != str
# Below IsCygwin() function copied from pylib/gyp/common.py
def IsCygwin():
try:
out = subprocess.Popen("uname",
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
stdout, stderr = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return "CYGWIN" in str(stdout)
except Exception:
return False
@ -27,7 +31,9 @@ def UnixifyPath(path):
out = subprocess.Popen(["cygpath", "-u", path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
stdout, stderr = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return str(stdout)
except Exception:
return path

View file

@ -11,6 +11,8 @@ import tempfile
import sys
import subprocess
PY3 = bytes != str
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
# among other "problems".
@ -623,7 +625,9 @@ def IsCygwin():
out = subprocess.Popen("uname",
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
stdout, stderr = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return "CYGWIN" in str(stdout)
except Exception:
return False