overwrite definition of where in requests.certs for different filesystem encodings
This commit is contained in:
parent
0d88d56ed8
commit
afc012ab63
2 changed files with 9 additions and 1 deletions
|
@ -40,6 +40,7 @@ elif is_py3: # pragma: nocover
|
||||||
open = open
|
open = open
|
||||||
basestring = (str, bytes)
|
basestring = (str, bytes)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
except ImportError: # pragma: nocover
|
except ImportError: # pragma: nocover
|
||||||
|
|
|
@ -11,6 +11,7 @@ If you are packaging Requests, e.g., for a Linux distribution or a managed
|
||||||
environment, you can change the definition of where() to return a separately
|
environment, you can change the definition of where() to return a separately
|
||||||
packaged CA bundle.
|
packaged CA bundle.
|
||||||
"""
|
"""
|
||||||
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -19,7 +20,13 @@ except ImportError:
|
||||||
def where():
|
def where():
|
||||||
"""Return the preferred certificate bundle."""
|
"""Return the preferred certificate bundle."""
|
||||||
# vendored bundle inside Requests
|
# vendored bundle inside Requests
|
||||||
return os.path.join(os.path.dirname(__file__), 'cacert.pem')
|
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')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(where())
|
print(where())
|
||||||
|
|
Loading…
Reference in a new issue