Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: third_party/google-endpoints/requests/packages/__init__.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 '''
2 Debian and other distributions "unbundle" requests' vendored dependencies, and
3 rewrite all imports to use the global versions of ``urllib3`` and ``chardet``.
4 The problem with this is that not only requests itself imports those
5 dependencies, but third-party code outside of the distros' control too.
6
7 In reaction to these problems, the distro maintainers replaced
8 ``requests.packages`` with a magical "stub module" that imports the correct
9 modules. The implementations were varying in quality and all had severe
10 problems. For example, a symlink (or hardlink) that links the correct modules
11 into place introduces problems regarding object identity, since you now have
12 two modules in `sys.modules` with the same API, but different identities::
13
14 requests.packages.urllib3 is not urllib3
15
16 With version ``2.5.2``, requests started to maintain its own stub, so that
17 distro-specific breakage would be reduced to a minimum, even though the whole
18 issue is not requests' fault in the first place. See
19 https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull
20 request.
21 '''
22
23 from __future__ import absolute_import
24 import sys
25
26 try:
27 from . import urllib3
28 except ImportError:
29 import urllib3
30 sys.modules['%s.urllib3' % __name__] = urllib3
31
32 try:
33 from . import chardet
34 except ImportError:
35 import chardet
36 sys.modules['%s.chardet' % __name__] = chardet
OLDNEW
« no previous file with comments | « third_party/google-endpoints/requests/models.py ('k') | third_party/google-endpoints/requests/packages/chardet/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698