1+'''2+Debian and other distributions "unbundle" requests' vendored dependencies, and3+rewrite all imports to use the global versions of ``urllib3`` and ``chardet``.4+The problem with this is that not only requests itself imports those5+dependencies, but third-party code outside of the distros' control too.6+7+In reaction to these problems, the distro maintainers replaced8+``requests.packages`` with a magical "stub module" that imports the correct9+modules. The implementations were varying in quality and all had severe10+problems. For example, a symlink (or hardlink) that links the correct modules11+into place introduces problems regarding object identity, since you now have12+two modules in `sys.modules` with the same API, but different identities::13+14+ requests.packages.urllib3 is not urllib315+16+With version ``2.5.2``, requests started to maintain its own stub, so that17+distro-specific breakage would be reduced to a minimum, even though the whole18+issue is not requests' fault in the first place. See19+https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull20+request.21+'''22+23from __future__ import absolute_import24+import sys2526+try:3-from . import urllib327+ from . import urllib328+except ImportError:29+ import urllib330+ sys.modules['%s.urllib3' % __name__] = urllib331+32+try:33+ from . import chardet34+except ImportError:35+ import chardet36+ sys.modules['%s.chardet' % __name__] = chardet
1If you are planning to submit a pull request to requests with any changes in 2-this library do not go any further. These are independent libraries which we 3-vendor into requests. Any changes necessary to these libraries must be made in 2+this library do not go any further. These are independent libraries which we3+vendor into requests. Any changes necessary to these libraries must be made in4them and submitted as separate pull requests to those libraries.56urllib3 pull requests go here: https://github.com/shazow/urllib378chardet pull requests go here: https://github.com/chardet/chardet9+10+See https://github.com/kennethreitz/requests/pull/1812#issuecomment-3085431611+for the reasoning behind this.