diff options
author | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2022-07-17 00:55:41 +0200 |
---|---|---|
committer | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2022-07-17 00:55:41 +0200 |
commit | f1b3926eaad22c4b4104c754b85ef19598ad7aeb (patch) | |
tree | 2f7495b0c8ff9bc67d68f390fb20429102666d6a /tools | |
parent | 51bb14be878d1a78fc8a561c515746f764f6c5b8 (diff) | |
download | pip-f1b3926eaad22c4b4104c754b85ef19598ad7aeb.tar.gz |
Vendoring: update requests patch
Diffstat (limited to 'tools')
-rw-r--r-- | tools/vendoring/patches/requests.patch | 96 |
1 files changed, 44 insertions, 52 deletions
diff --git a/tools/vendoring/patches/requests.patch b/tools/vendoring/patches/requests.patch index 670c1b0ca..f9c722dfe 100644 --- a/tools/vendoring/patches/requests.patch +++ b/tools/vendoring/patches/requests.patch @@ -1,22 +1,23 @@ diff --git a/src/pip/_vendor/requests/packages.py b/src/pip/_vendor/requests/packages.py -index 0f8ae0d38..9582fa730 100644 +index 77c45c9e..9582fa73 100644 --- a/src/pip/_vendor/requests/packages.py +++ b/src/pip/_vendor/requests/packages.py -@@ -1,26 +1,16 @@ +@@ -1,28 +1,16 @@ import sys - + -try: - import chardet -except ImportError: -- import charset_normalizer as chardet - import warnings - -- warnings.filterwarnings('ignore', 'Trying to detect', module='charset_normalizer') +- import charset_normalizer as chardet +- +- warnings.filterwarnings("ignore", "Trying to detect", module="charset_normalizer") - # This code exists for backwards compatibility reasons. # I don't like it either. Just look the other way. :) - --for package in ('urllib3', 'idna'): + +-for package in ("urllib3", "idna"): - locals()[package] = __import__(package) +for package in ('urllib3', 'idna', 'chardet'): + vendored_package = "pip._vendor." + package @@ -24,35 +25,36 @@ index 0f8ae0d38..9582fa730 100644 # This traversal is apparently necessary such that the identities are # preserved (requests.packages.urllib3.* is urllib3.*) for mod in list(sys.modules): -- if mod == package or mod.startswith(package + '.'): -- sys.modules['requests.packages.' + mod] = sys.modules[mod] +- if mod == package or mod.startswith(f"{package}."): +- sys.modules[f"requests.packages.{mod}"] = sys.modules[mod] + if mod == vendored_package or mod.startswith(vendored_package + '.'): + unprefixed_mod = mod[len("pip._vendor."):] + sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod] - + -target = chardet.__name__ -for mod in list(sys.modules): -- if mod == target or mod.startswith(target + '.'): -- sys.modules['requests.packages.' + target.replace(target, 'chardet')] = sys.modules[mod] +- if mod == target or mod.startswith(f"{target}."): +- target = target.replace(target, "chardet") +- sys.modules[f"requests.packages.{target}"] = sys.modules[mod] # Kinda cool, though, right? diff --git a/src/pip/_vendor/requests/__init__.py b/src/pip/_vendor/requests/__init__.py -index 973497f5e..4f80e28fc 100644 +index 7ac8e297..1e21e7e4 100644 --- a/src/pip/_vendor/requests/__init__.py +++ b/src/pip/_vendor/requests/__init__.py @@ -44,10 +44,7 @@ import urllib3 - import warnings + from .exceptions import RequestsDependencyWarning - + -try: - from charset_normalizer import __version__ as charset_normalizer_version -except ImportError: - charset_normalizer_version = None +charset_normalizer_version = None - + try: from chardet import __version__ as chardet_version -@@ -107,6 +104,11 @@ except (AssertionError, ValueError): +@@ -118,6 +115,11 @@ except (AssertionError, ValueError): # if the standard library doesn't support SNI or the # 'ssl' library isn't available. try: @@ -66,68 +68,58 @@ index 973497f5e..4f80e28fc 100644 except ImportError: diff --git a/src/pip/_vendor/requests/compat.py b/src/pip/_vendor/requests/compat.py -index 409b7b028..9e2937167 100644 +index 6776163c..8ff49e46 100644 --- a/src/pip/_vendor/requests/compat.py +++ b/src/pip/_vendor/requests/compat.py -@@ -8,10 +8,7 @@ This module handles import compatibility issues between Python 2 and - Python 3. +@@ -7,10 +7,7 @@ between Python 2 and Python 3. It remains for backwards + compatibility until the next major version. """ - + -try: - import chardet -except ImportError: - import charset_normalizer as chardet +import chardet - + import sys - -@@ -28,12 +28,14 @@ is_py2 = (_ver[0] == 2) + +@@ -27,19 +24,10 @@ is_py2 = _ver[0] == 2 #: Python 3.x? - is_py3 = (_ver[0] == 3) - + is_py3 = _ver[0] == 3 + +-# json/simplejson module import resolution -has_simplejson = False -try: - import simplejson as json +- - has_simplejson = True -except ImportError: - import json +- +-if has_simplejson: +- from simplejson import JSONDecodeError +-else: +- from json import JSONDecodeError +# Note: We've patched out simplejson support in pip because it prevents +# upgrading simplejson on Windows. -+# try: -+# import simplejson as json -+# except (ImportError, SyntaxError): -+# # simplejson does not support Python 3.2, it throws a SyntaxError -+# # because of u'...' Unicode literals. +import json - - # --------- - # Specifics -@@ -68,10 +70,7 @@ elif is_py3: - # Keep OrderedDict for backwards compatibility. - from collections import OrderedDict - from collections.abc import Callable, Mapping, MutableMapping -- if has_simplejson: -- from simplejson import JSONDecodeError -- else: -- from json import JSONDecodeError -+ from json import JSONDecodeError - - builtin_str = str - str = str - ++from json import JSONDecodeError + + # Keep OrderedDict for backwards compatibility. + from collections import OrderedDict diff --git a/src/pip/_vendor/requests/help.py b/src/pip/_vendor/requests/help.py -index 3a843404c..745f0d7b3 100644 +index 8fbcd656..c5e9c19e 100644 --- a/src/pip/_vendor/requests/help.py +++ b/src/pip/_vendor/requests/help.py -@@ -11,10 +11,7 @@ import urllib3 - +@@ -10,10 +10,7 @@ import urllib3 + from . import __version__ as requests_version - + -try: - import charset_normalizer -except ImportError: - charset_normalizer = None +charset_normalizer = None - + try: import chardet |