sslutil: abort when ssl module is needed but not found
authorMads Kiilerich <mads@kiilerich.com>
Tue, 27 Sep 2011 18:51:10 +0200
changeset 15160 b2d4400398f3
parent 15150 91dc8878f888
child 15161 f3edee8dc40c
sslutil: abort when ssl module is needed but not found It is apparently possible to compile Python without SSL support or leave it out when installing precompiled binaries. Mercurial on such Pythons would crash if the user tried to use https. Now it will be reported as "abort: Python SSL support not found" instead.
mercurial/sslutil.py
--- a/mercurial/sslutil.py	Thu Sep 22 15:15:18 2011 +0200
+++ b/mercurial/sslutil.py	Tue Sep 27 18:51:10 2011 +0200
@@ -22,6 +22,8 @@
 
     def ssl_wrap_socket(sock, key_file, cert_file,
                         cert_reqs=CERT_REQUIRED, ca_certs=None):
+        if not util.safehasattr(socket, 'ssl'):
+            raise util.Abort(_('Python SSL support not found'))
         if ca_certs:
             raise util.Abort(_(
                 'certificate checking requires Python 2.6'))