diff options
author | Mike Frysinger <vapier@google.com> | 2021-01-04 22:07:19 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-01-05 22:42:13 +0000 |
commit | ce9b6c43b2394f3f8c9413abfa3a10597de54223 (patch) | |
tree | 7720722129c6f2925fe044102accf7ad908a7475 | |
parent | 47692019b326a8c47aa579c0d9b92e0a3871800a (diff) | |
download | git-repo-ce9b6c43b2394f3f8c9413abfa3a10597de54223.tar.gz |
launcher: abort if python3 reexec failed
We don't support Python 2 anymore, so stop allowing it to fallback.
If we try to run the latest version with Python 2, it just hits
syntax errors which confuses people. Dump a clear error message
that their system is too old and give up.
Bug: https://crbug.com/gerrit/13795
Change-Id: I38c243cf09502f670cddad72c2d0148f736515e0
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292443
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-x | repo | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -103,8 +103,8 @@ def check_python_version(): | |||
103 | break | 103 | break |
104 | reexec('python{}.{}'.format(min_major, min_minor - inc)) | 104 | reexec('python{}.{}'.format(min_major, min_minor - inc)) |
105 | 105 | ||
106 | # Try the generic Python 3 wrapper, but only if it's new enough. We don't | 106 | # Try the generic Python 3 wrapper, but only if it's new enough. If it |
107 | # want to go from (still supported) Python 2.7 to (unsupported) Python 3.5. | 107 | # isn't, we want to just give up below and make the user resolve things. |
108 | try: | 108 | try: |
109 | proc = subprocess.Popen( | 109 | proc = subprocess.Popen( |
110 | ['python3', '-c', 'import sys; ' | 110 | ['python3', '-c', 'import sys; ' |
@@ -122,9 +122,10 @@ def check_python_version(): | |||
122 | 122 | ||
123 | # We're still here, so diagnose things for the user. | 123 | # We're still here, so diagnose things for the user. |
124 | if major < 3: | 124 | if major < 3: |
125 | print('repo: warning: Python 2 is no longer supported; ' | 125 | print('repo: error: Python 2 is no longer supported; ' |
126 | 'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION_HARD), | 126 | 'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION_HARD), |
127 | file=sys.stderr) | 127 | file=sys.stderr) |
128 | sys.exit(1) | ||
128 | elif (major, minor) < MIN_PYTHON_VERSION_HARD: | 129 | elif (major, minor) < MIN_PYTHON_VERSION_HARD: |
129 | print('repo: error: Python 3 version is too old; ' | 130 | print('repo: error: Python 3 version is too old; ' |
130 | 'Please use Python {}.{} or newer.'.format(*MIN_PYTHON_VERSION_HARD), | 131 | 'Please use Python {}.{} or newer.'.format(*MIN_PYTHON_VERSION_HARD), |