From de43800deb2fa524eea054d1e8b7185814d58dbb Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sat, 13 Oct 2018 21:17:56 +0200 Subject: [PATCH 2/2] pygnulib: Don't crash immediately on older Python versions * pygnulib/constants.py: sys.version_info is a named tuple only since Python 2.7. Use the indexed version to support older versions. Exit out if the installed Python is older than 2.7. --- ChangeLog | 6 ++++++ pygnulib/constants.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b0aa8e29d..c15ba9736 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-10-13 Darshit Shah + + * pygnulib/constants.py: sys.version_info is a named tuple only since + Python 2.7. Use the indexed version to support older versions. + Exit out if the installed Python is older than 2.7. + 2018-10-13 Darshit Shah * bootstrap.conf: Introduce option use_pygnulib diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 2dc64e6b6..e6d23cf54 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -34,11 +34,17 @@ __copyright__ = '2002-2017 Free Software Foundation, Inc.' # Backward compatibility #=============================================================================== # Check for Python version -if sys.version_info.major == 2: +if sys.version_info[0] == 2: PYTHON3 = False else: PYTHON3 = True +# If using Python 2, ensure that at least version 2.7 is used. Older versions +# are not supported +if not PYTHON3 or sys.version_info[1] < 7: + print("Python version must be atleast 2.7. Exiting.") + sys.exit(1) + # Create string compatibility if not PYTHON3: string = unicode -- 2.19.1