Skip to content

Commit

Permalink
gyp: more decode stdout on Python 3
Browse files Browse the repository at this point in the history
PR-URL: #1894
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
  • Loading branch information
cclauss authored and rvagg committed Sep 27, 2019
1 parent f753c16 commit 36638af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions gyp/gyp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import sys
import subprocess

PY3 = bytes != str


# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
# among other "problems".
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 36638af

Please sign in to comment.