encode certfile path as utf-8 in python3 for Windows systems not using utf-8 as default filesystem encoding

This commit is contained in:
Alan Hamlett 2015-08-24 10:58:42 -07:00
parent 43c461a7cc
commit bba2015d9b

View file

@ -21,12 +21,8 @@ except ImportError:
"""Return the preferred certificate bundle."""
# vendored bundle inside Requests
is_py3 = (sys.version_info[0] == 3)
certdir = os.path.dirname(
__file__
if is_py3 else
__file__.decode(sys.getfilesystemencoding())
)
return os.path.join(certdir, 'cacert.pem')
cacert = os.path.join(os.path.dirname(__file__), 'cacert.pem')
return cacert.encode('utf-8') if is_py3 else cacert
if __name__ == '__main__':
print(where())