setup: require a Python version with modern SSL features
This increases the minimum security baseline of Mercurial and enables us to
remove compatibility code for supporting older, less secure Python versions.
--- a/setup.py Sat May 30 03:46:59 2020 +0200
+++ b/setup.py Fri May 29 21:07:26 2020 +0200
@@ -83,6 +83,21 @@
printf(error, file=sys.stderr)
sys.exit(1)
+import ssl
+
+try:
+ ssl.SSLContext
+except AttributeError:
+ error = """
+The `ssl` module does not have the `SSLContext` class. This indicates an old
+Python version which does not support modern security features (which were
+added to Python 2.7 as part of "PEP 466"). Please make sure you have installed
+at least Python 2.7.9 or a Python version with backports of these security
+features.
+"""
+ printf(error, file=sys.stderr)
+ sys.exit(1)
+
if sys.version_info[0] >= 3:
DYLIB_SUFFIX = sysconfig.get_config_vars()['EXT_SUFFIX']
else: