changeset 15160:b2d4400398f3

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.
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 27 Sep 2011 18:51:10 +0200
parents 91dc8878f888
children f3edee8dc40c
files mercurial/sslutil.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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'))