Skip to content

Commit 67dec14

Browse files
cclaussrvagg
authored andcommitted
gyp: more decode stdout on Python 3
PR-URL: #1894 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent d90d9c5 commit 67dec14

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

gyp/gyp_main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
import sys
99
import subprocess
1010

11+
PY3 = bytes != str
12+
1113
# Below IsCygwin() function copied from pylib/gyp/common.py
1214
def IsCygwin():
1315
try:
1416
out = subprocess.Popen("uname",
1517
stdout=subprocess.PIPE,
1618
stderr=subprocess.STDOUT)
17-
stdout,stderr = out.communicate()
19+
stdout, stderr = out.communicate()
20+
if PY3:
21+
stdout = stdout.decode("utf-8")
1822
return "CYGWIN" in str(stdout)
1923
except Exception:
2024
return False
@@ -27,7 +31,9 @@ def UnixifyPath(path):
2731
out = subprocess.Popen(["cygpath", "-u", path],
2832
stdout=subprocess.PIPE,
2933
stderr=subprocess.STDOUT)
30-
stdout,stderr = out.communicate()
34+
stdout, stderr = out.communicate()
35+
if PY3:
36+
stdout = stdout.decode("utf-8")
3137
return str(stdout)
3238
except Exception:
3339
return path

gyp/pylib/gyp/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import sys
1212
import subprocess
1313

14+
PY3 = bytes != str
15+
1416

1517
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
1618
# among other "problems".
@@ -623,7 +625,9 @@ def IsCygwin():
623625
out = subprocess.Popen("uname",
624626
stdout=subprocess.PIPE,
625627
stderr=subprocess.STDOUT)
626-
stdout,stderr = out.communicate()
628+
stdout, stderr = out.communicate()
629+
if PY3:
630+
stdout = stdout.decode("utf-8")
627631
return "CYGWIN" in str(stdout)
628632
except Exception:
629633
return False

0 commit comments

Comments
 (0)