Skip to content

Commit 19398a4

Browse files
committed
Decode stdout on Python 3
1 parent 0a4d8c8 commit 19398a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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)