diff options
Diffstat (limited to 'requests')
-rw-r--r-- | requests/certs.py | 4 | ||||
-rw-r--r-- | requests/compat.py | 2 | ||||
-rw-r--r-- | requests/packages/__init__.py | 35 |
3 files changed, 38 insertions, 3 deletions
diff --git a/requests/certs.py b/requests/certs.py index 07e6475..e61ee5d 100644 --- a/requests/certs.py +++ b/requests/certs.py @@ -18,8 +18,8 @@ try: except ImportError: def where(): """Return the preferred certificate bundle.""" - # vendored bundle inside Requests - return os.path.join(os.path.dirname(__file__), 'cacert.pem') + # On Debian systems use ca-certificates + return '/etc/ssl/certs/ca-certificates.crt' if __name__ == '__main__': print(where()) diff --git a/requests/compat.py b/requests/compat.py index 70edff7..a338846 100644 --- a/requests/compat.py +++ b/requests/compat.py @@ -40,6 +40,7 @@ if is_py2: from Cookie import Morsel from StringIO import StringIO from .packages.urllib3.packages.ordered_dict import OrderedDict + from httplib import IncompleteRead builtin_str = str bytes = str @@ -54,6 +55,7 @@ elif is_py3: from http.cookies import Morsel from io import StringIO from collections import OrderedDict + from http.client import IncompleteRead builtin_str = str str = str diff --git a/requests/packages/__init__.py b/requests/packages/__init__.py index d62c4b7..971c2ad 100644 --- a/requests/packages/__init__.py +++ b/requests/packages/__init__.py @@ -1,3 +1,36 @@ +''' +Debian and other distributions "unbundle" requests' vendored dependencies, and +rewrite all imports to use the global versions of ``urllib3`` and ``chardet``. +The problem with this is that not only requests itself imports those +dependencies, but third-party code outside of the distros' control too. + +In reaction to these problems, the distro maintainers replaced +``requests.packages`` with a magical "stub module" that imports the correct +modules. The implementations were varying in quality and all had severe +problems. For example, a symlink (or hardlink) that links the correct modules +into place introduces problems regarding object identity, since you now have +two modules in `sys.modules` with the same API, but different identities:: + + requests.packages.urllib3 is not urllib3 + +With version ``2.5.2``, requests started to maintain its own stub, so that +distro-specific breakage would be reduced to a minimum, even though the whole +issue is not requests' fault in the first place. See +https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull +request. +''' + from __future__ import absolute_import +import sys + +try: + from . import urllib3 +except ImportError: + import urllib3 + sys.modules['%s.urllib3' % __name__] = urllib3 -from . import urllib3 +try: + from . import chardet +except ImportError: + import chardet + sys.modules['%s.chardet' % __name__] = chardet |