Skip to content

Commit d90d9c5

Browse files
cclaussrvagg
authored andcommitted
gyp: decode stdout on Python 3
PR-URL: #1890 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 8d4ea7f commit d90d9c5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ matrix:
6161
EXPERIMENTAL_NODE_GYP_PYTHON3=1
6262
before_install: choco install python
6363

64-
allow_failures:
65-
- os: osx
66-
env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
6764
install:
6865
#- pip install -r requirements.txt
6966
- pip install flake8 # pytest # add another testing frameworks later

gyp/pylib/gyp/xcode_emulation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import tempfile
2121
from gyp.common import GypError
2222

23+
PY3 = bytes != str
24+
2325
# Populated lazily by XcodeVersion, for efficiency, and to fix an issue when
2426
# "xcodebuild" is called too quickly (it has been found to return incorrect
2527
# version number).
@@ -1277,7 +1279,7 @@ def XcodeVersion():
12771279
except:
12781280
version = CLTVersion()
12791281
if version:
1280-
version = re.match(r'(\d+\.\d+\.?\d*)', version).groups()[0]
1282+
version = ".".join(version.split(".")[:3])
12811283
else:
12821284
raise GypError("No Xcode or CLT version detected!")
12831285
# The CLT has no build information, so we return an empty string.
@@ -1322,6 +1324,8 @@ def GetStdoutQuiet(cmdlist):
13221324
Raises |GypError| if the command return with a non-zero return code."""
13231325
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
13241326
out = job.communicate()[0]
1327+
if PY3:
1328+
out = out.decode("utf-8")
13251329
if job.returncode != 0:
13261330
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
13271331
return out.rstrip('\n')
@@ -1332,6 +1336,8 @@ def GetStdout(cmdlist):
13321336
Raises |GypError| if the command return with a non-zero return code."""
13331337
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
13341338
out = job.communicate()[0]
1339+
if PY3:
1340+
out = out.decode("utf-8")
13351341
if job.returncode != 0:
13361342
sys.stderr.write(out + '\n')
13371343
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))

0 commit comments

Comments
 (0)