Patchwork [1,of,2] packaging: don't crash building wix with python3.6 and earlier

login
register
mail settings
Submitter Matt Harbison
Date April 6, 2019, 3:11 a.m.
Message ID <385b6be9f587e3ec2bc0.1554520295@Envy>
Download mbox | patch
Permalink /patch/39523/
State Accepted
Headers show

Comments

Matt Harbison - April 6, 2019, 3:11 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1554518865 14400
#      Fri Apr 05 22:47:45 2019 -0400
# Node ID 385b6be9f587e3ec2bc04de98d5ffe025a375e8f
# Parent  7cfd20bc07215ce8d18642dfe67f316405208c06
packaging: don't crash building wix with python3.6 and earlier

`capture_output` was added in 3.7.  I was tempted to just check and abort in
build.py, since Windows doesn't have the Linux problem where some distros only
ship an older python.  But this is in a library that could be used elsewhere in
the future.

Patch

diff --git a/contrib/packaging/hgpackaging/util.py b/contrib/packaging/hgpackaging/util.py
--- a/contrib/packaging/hgpackaging/util.py
+++ b/contrib/packaging/hgpackaging/util.py
@@ -142,11 +142,9 @@  import platform; print("%s:%s" % (platfo
 def python_exe_info(python_exe: pathlib.Path):
     """Obtain information about a Python executable."""
 
-    res = subprocess.run(
-        [str(python_exe), '-c', PRINT_PYTHON_INFO],
-        capture_output=True, check=True)
+    res = subprocess.check_output([str(python_exe), '-c', PRINT_PYTHON_INFO])
 
-    arch, version = res.stdout.decode('utf-8').split(':')
+    arch, version = res.decode('utf-8').split(':')
 
     version = distutils.version.LooseVersion(version)