Mercurial > hg
comparison mercurial/sslutil.py @ 29927:799e36749f1a
ssl: handle a difference in SSLError with pypy (issue5348)
The SSLError exception is a bit different with pypy (message is the first
argument, not the second) This led the certificate error handling to crash when
trying to extract the ssl error message. We now handle this different and
'test-https.t' is green again.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 13 Sep 2016 17:46:29 +0200 |
parents | 387bdd53c77e |
children | b9f7b0c10027 |
comparison
equal
deleted
inserted
replaced
29926:be16091ac14d | 29927:799e36749f1a |
---|---|
388 | 388 |
389 if settings['cafile'] is not None: | 389 if settings['cafile'] is not None: |
390 try: | 390 try: |
391 sslcontext.load_verify_locations(cafile=settings['cafile']) | 391 sslcontext.load_verify_locations(cafile=settings['cafile']) |
392 except ssl.SSLError as e: | 392 except ssl.SSLError as e: |
393 if len(e.args) == 1: # pypy has different SSLError args | |
394 msg = e.args[0] | |
395 else: | |
396 msg = e.args[1] | |
393 raise error.Abort(_('error loading CA file %s: %s') % ( | 397 raise error.Abort(_('error loading CA file %s: %s') % ( |
394 settings['cafile'], e.args[1]), | 398 settings['cafile'], msg), |
395 hint=_('file is empty or malformed?')) | 399 hint=_('file is empty or malformed?')) |
396 caloaded = True | 400 caloaded = True |
397 elif settings['allowloaddefaultcerts']: | 401 elif settings['allowloaddefaultcerts']: |
398 # This is a no-op on old Python. | 402 # This is a no-op on old Python. |
399 sslcontext.load_default_certs() | 403 sslcontext.load_default_certs() |