setup: require a Python version with modern SSL features
authorManuel Jacob <me@manueljacob.de>
Fri, 29 May 2020 21:07:26 +0200
changeset 44874 4c53c12b92d5
parent 44873 47b3c8383cc1
child 44875 7c19eb372438
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.
setup.py
--- 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: