Mercurial > public > mercurial-scm > hg
comparison mercurial/sslutil.py @ 41410:0d226b2139df
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 26 Jan 2019 13:58:58 -0800 |
parents | 67dc32d4e790 |
children | f07aff7e8b5a |
comparison
equal
deleted
inserted
replaced
41409:1db94ebbc207 | 41410:0d226b2139df |
---|---|
428 'https://mercurial-scm.org/wiki/SecureConnections ' | 428 'https://mercurial-scm.org/wiki/SecureConnections ' |
429 'for how to configure Mercurial to avoid this ' | 429 'for how to configure Mercurial to avoid this ' |
430 'error)\n')) | 430 'error)\n')) |
431 except ssl.SSLError: | 431 except ssl.SSLError: |
432 pass | 432 pass |
433 | |
433 # Try to print more helpful error messages for known failures. | 434 # Try to print more helpful error messages for known failures. |
434 if util.safehasattr(e, 'reason'): | 435 if util.safehasattr(e, 'reason'): |
435 # This error occurs when the client and server don't share a | 436 # This error occurs when the client and server don't share a |
436 # common/supported SSL/TLS protocol. We've disabled SSLv2 and SSLv3 | 437 # common/supported SSL/TLS protocol. We've disabled SSLv2 and SSLv3 |
437 # outright. Hopefully the reason for this error is that we require | 438 # outright. Hopefully the reason for this error is that we require |
438 # TLS 1.1+ and the server only supports TLS 1.0. Whatever the | 439 # TLS 1.1+ and the server only supports TLS 1.0. Whatever the |
439 # reason, try to emit an actionable warning. | 440 # reason, try to emit an actionable warning. |
440 if e.reason == 'UNSUPPORTED_PROTOCOL': | 441 if e.reason == r'UNSUPPORTED_PROTOCOL': |
441 # We attempted TLS 1.0+. | 442 # We attempted TLS 1.0+. |
442 if settings['protocolui'] == 'tls1.0': | 443 if settings['protocolui'] == 'tls1.0': |
443 # We support more than just TLS 1.0+. If this happens, | 444 # We support more than just TLS 1.0+. If this happens, |
444 # the likely scenario is either the client or the server | 445 # the likely scenario is either the client or the server |
445 # is really old. (e.g. server doesn't support TLS 1.0+ or | 446 # is really old. (e.g. server doesn't support TLS 1.0+ or |
482 serverhostname) | 483 serverhostname) |
483 ui.warn(_( | 484 ui.warn(_( |
484 '(see https://mercurial-scm.org/wiki/SecureConnections ' | 485 '(see https://mercurial-scm.org/wiki/SecureConnections ' |
485 'for more info)\n')) | 486 'for more info)\n')) |
486 | 487 |
487 elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and | 488 elif (e.reason == r'CERTIFICATE_VERIFY_FAILED' and |
488 pycompat.iswindows): | 489 pycompat.iswindows): |
489 | 490 |
490 ui.warn(_('(the full certificate chain may not be available ' | 491 ui.warn(_('(the full certificate chain may not be available ' |
491 'locally; see "hg help debugssl")\n')) | 492 'locally; see "hg help debugssl")\n')) |
492 raise | 493 raise |