From 172c58398b340f30bad1902aebba9d198b5786f4 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Fri, 3 Nov 2023 17:22:40 +0100 Subject: [PATCH] repo: Drop reexec of python3 from check_python_version() This simplifies check_python_version() since there is no point in trying to fall back to python3, as we are already running using some Python 3 interpreter. Change-Id: I9dfdd002b4ef5567e064d3d6ca98ee1f3410fd48 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/397759 Reviewed-by: Mike Frysinger Tested-by: Peter Kjellerstedt Commit-Queue: Peter Kjellerstedt --- repo | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/repo b/repo index 908ad021..b598c327 100755 --- a/repo +++ b/repo @@ -79,7 +79,7 @@ def check_python_version(): major = ver.major minor = ver.minor - # Try to re-exec the version specific Python 3 if needed. + # Try to re-exec the version specific Python if needed. if (major, minor) < MIN_PYTHON_VERSION_SOFT: # Python makes releases ~once a year, so try our min version +10 to help # bridge the gap. This is the fallback anyways so perf isn't critical. @@ -96,36 +96,10 @@ def check_python_version(): break reexec(f"python{min_major}.{min_minor - inc}") - # Try the generic Python 3 wrapper, but only if it's new enough. If it - # isn't, we want to just give up below and make the user resolve things. - try: - proc = subprocess.Popen( - [ - "python3", - "-c", - "import sys; " - "print(sys.version_info.major, sys.version_info.minor)", - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - (output, _) = proc.communicate() - python3_ver = tuple(int(x) for x in output.decode("utf-8").split()) - except (OSError, subprocess.CalledProcessError): - python3_ver = None - - # If the python3 version looks like it's new enough, give it a try. - if ( - python3_ver - and python3_ver >= MIN_PYTHON_VERSION_HARD - and python3_ver != (major, minor) - ): - reexec("python3") - # We're still here, so diagnose things for the user. if (major, minor) < MIN_PYTHON_VERSION_HARD: print( - "repo: error: Python 3 version is too old; " + "repo: error: Python version is too old; " "Please use Python {}.{} or newer.".format( *MIN_PYTHON_VERSION_HARD ),