summaryrefslogtreecommitdiff
path: root/buildscripts/utils.py
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2019-02-19 10:50:57 -0500
committerMathew Robinson <chasinglogic@gmail.com>2019-04-08 14:08:49 -0400
commit8dd6d4755734ed37c1b98dfdefce3ca6bc65f1f6 (patch)
tree69e936c4953cbead2e3bae2690157c5fe75e709d /buildscripts/utils.py
parentc600aa9d7423eca8151daf626e2799d9a6c7b31c (diff)
downloadmongo-8dd6d4755734ed37c1b98dfdefce3ca6bc65f1f6.tar.gz
SERVER-32295 Support Python 3
Diffstat (limited to 'buildscripts/utils.py')
-rw-r--r--buildscripts/utils.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/buildscripts/utils.py b/buildscripts/utils.py
index 5073b26ad85..57d3f5da3a2 100644
--- a/buildscripts/utils.py
+++ b/buildscripts/utils.py
@@ -99,7 +99,7 @@ def get_git_describe():
with open(os.devnull, "r+") as devnull:
proc = subprocess.Popen("git describe", stdout=subprocess.PIPE, stderr=devnull,
stdin=devnull, shell=True)
- return proc.communicate()[0].strip()
+ return proc.communicate()[0].strip().decode('utf-8')
def execsys(args):
@@ -130,11 +130,10 @@ def which(executable):
return executable
-def find_python(min_version=(2, 5)):
+def find_python(min_version=(3, 7)):
"""Return path of python."""
try:
- if sys.version_info >= min_version:
- return sys.executable
+ return sys.executable
except AttributeError:
# In case the version of Python is somehow missing sys.version_info or sys.executable.
pass
@@ -154,8 +153,8 @@ def find_python(min_version=(2, 5)):
except Exception: # pylint: disable=broad-except
pass
- raise Exception("could not find suitable Python (version >= %s)" % ".".join(
- str(v) for v in min_version))
+ raise Exception(
+ "could not find suitable Python (version >= %s)" % ".".join(str(v) for v in min_version))
def replace_with_repr(unicode_error):
@@ -166,7 +165,7 @@ def replace_with_repr(unicode_error):
# repr() of the offending bytes into the decoded string
# at the position they occurred
offender = unicode_error.object[unicode_error.start:unicode_error.end]
- return (unicode(repr(offender).strip("'").strip('"')), unicode_error.end)
+ return (str(repr(offender).strip("'").strip('"')), unicode_error.end)
codecs.register_error("repr", replace_with_repr)