comparison mercurial/sslutil.py @ 30639:d524c88511a7

py3: replace os.name with pycompat.osname (part 1 of 2) os.name returns unicodes on py3 and we have pycompat.osname which returns bytes. This series of 2 patches will change every ocurrence of os.name with pycompat.osname.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Dec 2016 00:16:52 +0530
parents 318a24b52eeb
children 16b5df5792a8
comparison
equal deleted inserted replaced
30638:1c5cbf28f007 30639:d524c88511a7
16 import sys 16 import sys
17 17
18 from .i18n import _ 18 from .i18n import _
19 from . import ( 19 from . import (
20 error, 20 error,
21 pycompat,
21 util, 22 util,
22 ) 23 )
23 24
24 # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added 25 # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added
25 # support for TLS 1.1, TLS 1.2, SNI, system CA stores, etc. These features are 26 # support for TLS 1.1, TLS 1.2, SNI, system CA stores, etc. These features are
704 # On Windows, only the modern ssl module is capable of loading the system 705 # On Windows, only the modern ssl module is capable of loading the system
705 # CA certificates. If we're not capable of doing that, emit a warning 706 # CA certificates. If we're not capable of doing that, emit a warning
706 # because we'll get a certificate verification error later and the lack 707 # because we'll get a certificate verification error later and the lack
707 # of loaded CA certificates will be the reason why. 708 # of loaded CA certificates will be the reason why.
708 # Assertion: this code is only called if certificates are being verified. 709 # Assertion: this code is only called if certificates are being verified.
709 if os.name == 'nt': 710 if pycompat.osname == 'nt':
710 if not _canloaddefaultcerts: 711 if not _canloaddefaultcerts:
711 ui.warn(_('(unable to load Windows CA certificates; see ' 712 ui.warn(_('(unable to load Windows CA certificates; see '
712 'https://mercurial-scm.org/wiki/SecureConnections for ' 713 'https://mercurial-scm.org/wiki/SecureConnections for '
713 'how to configure Mercurial to avoid this message)\n')) 714 'how to configure Mercurial to avoid this message)\n'))
714 715
735 return None 736 return None
736 737
737 # / is writable on Windows. Out of an abundance of caution make sure 738 # / is writable on Windows. Out of an abundance of caution make sure
738 # we're not on Windows because paths from _systemcacerts could be installed 739 # we're not on Windows because paths from _systemcacerts could be installed
739 # by non-admin users. 740 # by non-admin users.
740 assert os.name != 'nt' 741 assert pycompat.osname != 'nt'
741 742
742 # Try to find CA certificates in well-known locations. We print a warning 743 # Try to find CA certificates in well-known locations. We print a warning
743 # when using a found file because we don't want too much silent magic 744 # when using a found file because we don't want too much silent magic
744 # for security settings. The expectation is that proper Mercurial 745 # for security settings. The expectation is that proper Mercurial
745 # installs will have the CA certs path defined at install time and the 746 # installs will have the CA certs path defined at install time and the