From 36638afe480bc90bc004083f2a882e225b2a086f Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 26 Sep 2019 11:29:03 +0200 Subject: [PATCH] gyp: more decode stdout on Python 3 PR-URL: https://github.com/nodejs/node-gyp/pull/1894 Reviewed-By: Ben Noordhuis Reviewed-By: Sam Roberts --- gyp/gyp_main.py | 10 ++++++++-- gyp/pylib/gyp/common.py | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gyp/gyp_main.py b/gyp/gyp_main.py index 8dfc552e81..aece53c8eb 100755 --- a/gyp/gyp_main.py +++ b/gyp/gyp_main.py @@ -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 @@ -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 diff --git a/gyp/pylib/gyp/common.py b/gyp/pylib/gyp/common.py index 8296d11fc3..071ad7e242 100644 --- a/gyp/pylib/gyp/common.py +++ b/gyp/pylib/gyp/common.py @@ -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". @@ -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