sagemath / sage-patchbot

Sage Patchbot
https://www.sagemath.org
Other
8 stars 17 forks source link

compatibility with Python 3.6 #146

Closed videlec closed 2 years ago

videlec commented 3 years ago

The following broke the compatibility with Python 3.6 (maintained until Dec 2021)

commit b36579a407ced7ce55a9503a60098f38e5ef4de4 (HEAD -> master, origin/master, origin/HEAD)
Author: Frédéric Chapoton <chapoton@unistra.fr>
Date:   Wed Apr 7 13:53:20 2021 +0200

    fix enhanced python version

diff --git a/sage_patchbot/util.py b/sage_patchbot/util.py
index 130e6c4..3f93752 100644
--- a/sage_patchbot/util.py
+++ b/sage_patchbot/util.py
@@ -250,9 +250,9 @@ def get_python_version(sage_cmd) -> str:
     # return int(res[0])
     # code above for future use

-    res = subprocess.check_output([sage_cmd, "--python", "--version"],
-                                  stderr=subprocess.STDOUT)
-    return str(res).split(" ")[1]
+    res = subprocess.run([sage_cmd, "--python", "--version"],
+                         capture_output=True, text=True).stdout
+    return res.strip().split(" ")[1]

 def describe_branch(branch, tag_only=False):
fchapoton commented 3 years ago

Vraiment ? run a été introduit dans python 3.5 : https://python.readthedocs.io/en/stable/library/subprocess.html#using-the-subprocess-module

videlec commented 3 years ago

Vraiment ? run a été introduit dans python 3.5 : https://python.readthedocs.io/en/stable/library/subprocess.html#using-the-subprocess-module

Pas l'option capture_output.

videlec commented 2 years ago

Since Python 3.6 is gone I close the issue.