Mercurial > public > mercurial-scm > hg
comparison mercurial/sslutil.py @ 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 | 8f12dac18d13 |
children | 0cc4ad757c77 |
comparison
equal
deleted
inserted
replaced
15150:91dc8878f888 | 15160:b2d4400398f3 |
---|---|
20 | 20 |
21 import socket, httplib | 21 import socket, httplib |
22 | 22 |
23 def ssl_wrap_socket(sock, key_file, cert_file, | 23 def ssl_wrap_socket(sock, key_file, cert_file, |
24 cert_reqs=CERT_REQUIRED, ca_certs=None): | 24 cert_reqs=CERT_REQUIRED, ca_certs=None): |
25 if not util.safehasattr(socket, 'ssl'): | |
26 raise util.Abort(_('Python SSL support not found')) | |
25 if ca_certs: | 27 if ca_certs: |
26 raise util.Abort(_( | 28 raise util.Abort(_( |
27 'certificate checking requires Python 2.6')) | 29 'certificate checking requires Python 2.6')) |
28 | 30 |
29 ssl = socket.ssl(sock, key_file, cert_file) | 31 ssl = socket.ssl(sock, key_file, cert_file) |