ssl: handle a difference in SSLError with pypy (issue5348)
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 13 Sep 2016 17:46:29 +0200
changeset 29927 799e36749f1a
parent 29926 be16091ac14d
child 29928 e5a97ec6ebb8
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.
mercurial/sslutil.py
--- a/mercurial/sslutil.py	Mon Sep 12 10:55:43 2016 -0700
+++ b/mercurial/sslutil.py	Tue Sep 13 17:46:29 2016 +0200
@@ -390,8 +390,12 @@
         try:
             sslcontext.load_verify_locations(cafile=settings['cafile'])
         except ssl.SSLError as e:
+            if len(e.args) == 1: # pypy has different SSLError args
+                msg = e.args[0]
+            else:
+                msg = e.args[1]
             raise error.Abort(_('error loading CA file %s: %s') % (
-                              settings['cafile'], e.args[1]),
+                              settings['cafile'], msg),
                               hint=_('file is empty or malformed?'))
         caloaded = True
     elif settings['allowloaddefaultcerts']: