sslutil: use raw strings for exception reason compare
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 26 Jan 2019 13:58:58 -0800
changeset 41410 0d226b2139df
parent 41409 1db94ebbc207
child 41411 f07aff7e8b5a
sslutil: use raw strings for exception reason compare Otherwise we attempt to compare a bytes to a str on Python 3 and it always fails. Differential Revision: https://phab.mercurial-scm.org/D5721
mercurial/sslutil.py
--- a/mercurial/sslutil.py	Sat Jan 26 13:40:44 2019 -0800
+++ b/mercurial/sslutil.py	Sat Jan 26 13:58:58 2019 -0800
@@ -430,6 +430,7 @@
                           'error)\n'))
         except ssl.SSLError:
             pass
+
         # Try to print more helpful error messages for known failures.
         if util.safehasattr(e, 'reason'):
             # This error occurs when the client and server don't share a
@@ -437,7 +438,7 @@
             # outright. Hopefully the reason for this error is that we require
             # TLS 1.1+ and the server only supports TLS 1.0. Whatever the
             # reason, try to emit an actionable warning.
-            if e.reason == 'UNSUPPORTED_PROTOCOL':
+            if e.reason == r'UNSUPPORTED_PROTOCOL':
                 # We attempted TLS 1.0+.
                 if settings['protocolui'] == 'tls1.0':
                     # We support more than just TLS 1.0+. If this happens,
@@ -484,7 +485,7 @@
                         '(see https://mercurial-scm.org/wiki/SecureConnections '
                         'for more info)\n'))
 
-            elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and
+            elif (e.reason == r'CERTIFICATE_VERIFY_FAILED' and
                 pycompat.iswindows):
 
                 ui.warn(_('(the full certificate chain may not be available '