requests.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. diff --git a/src/pip/_vendor/requests/packages.py b/src/pip/_vendor/requests/packages.py
  2. index 6336a07d..9582fa73 100644
  3. --- a/src/pip/_vendor/requests/packages.py
  4. +++ b/src/pip/_vendor/requests/packages.py
  5. @@ -4,11 +4,13 @@ import sys
  6. # I don't like it either. Just look the other way. :)
  7. for package in ('urllib3', 'idna', 'chardet'):
  8. - locals()[package] = __import__(package)
  9. + vendored_package = "pip._vendor." + package
  10. + locals()[package] = __import__(vendored_package)
  11. # This traversal is apparently necessary such that the identities are
  12. # preserved (requests.packages.urllib3.* is urllib3.*)
  13. for mod in list(sys.modules):
  14. - if mod == package or mod.startswith(package + '.'):
  15. - sys.modules['requests.packages.' + mod] = sys.modules[mod]
  16. + if mod == vendored_package or mod.startswith(vendored_package + '.'):
  17. + unprefixed_mod = mod[len("pip._vendor."):]
  18. + sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
  19. # Kinda cool, though, right?
  20. diff --git a/src/pip/_vendor/requests/__init__.py b/src/pip/_vendor/requests/__init__.py
  21. index 9c3b769..36a4ef40 100644
  22. --- a/src/pip/_vendor/requests/__init__.py
  23. +++ b/src/pip/_vendor/requests/__init__.py
  24. @@ -80,13 +80,15 @@ except (AssertionError, ValueError):
  25. RequestsDependencyWarning)
  26. # Attempt to enable urllib3's SNI support, if possible
  27. -try:
  28. - from pip._vendor.urllib3.contrib import pyopenssl
  29. - pyopenssl.inject_into_urllib3()
  30. -
  31. - # Check cryptography version
  32. - from cryptography import __version__ as cryptography_version
  33. - _check_cryptography(cryptography_version)
  34. -except ImportError:
  35. - pass
  36. +from pip._internal.utils.compat import WINDOWS
  37. +if not WINDOWS:
  38. + try:
  39. + from pip._vendor.urllib3.contrib import pyopenssl
  40. + pyopenssl.inject_into_urllib3()
  41. +
  42. + # Check cryptography version
  43. + from cryptography import __version__ as cryptography_version
  44. + _check_cryptography(cryptography_version)
  45. + except ImportError:
  46. + pass
  47. # urllib3's DependencyWarnings should be silenced.
  48. diff --git a/src/pip/_vendor/requests/compat.py b/src/pip/_vendor/requests/compat.py
  49. index eb6530d..353ec29 100644
  50. --- a/src/pip/_vendor/requests/compat.py
  51. +++ b/src/pip/_vendor/requests/compat.py
  52. @@ -25,10 +25,14 @@
  53. #: Python 3.x?
  54. is_py3 = (_ver[0] == 3)
  55. -try:
  56. - import simplejson as json
  57. -except ImportError:
  58. - import json
  59. +# Note: We've patched out simplejson support in pip because it prevents
  60. +# upgrading simplejson on Windows.
  61. +# try:
  62. +# import simplejson as json
  63. +# except (ImportError, SyntaxError):
  64. +# # simplejson does not support Python 3.2, it throws a SyntaxError
  65. +# # because of u'...' Unicode literals.
  66. +import json
  67. # ---------
  68. # Specifics