Skip to content

Commit f1b3926

Browse files
committed
Vendoring: update requests patch
1 parent 51bb14b commit f1b3926

File tree

1 file changed

+44
-52
lines changed

1 file changed

+44
-52
lines changed
Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
11
diff --git a/src/pip/_vendor/requests/packages.py b/src/pip/_vendor/requests/packages.py
2-
index 0f8ae0d38..9582fa730 100644
2+
index 77c45c9e..9582fa73 100644
33
--- a/src/pip/_vendor/requests/packages.py
44
+++ b/src/pip/_vendor/requests/packages.py
5-
@@ -1,26 +1,16 @@
5+
@@ -1,28 +1,16 @@
66
import sys
7-
7+
88
-try:
99
- import chardet
1010
-except ImportError:
11-
- import charset_normalizer as chardet
1211
- import warnings
1312
-
14-
- warnings.filterwarnings('ignore', 'Trying to detect', module='charset_normalizer')
13+
- import charset_normalizer as chardet
14+
-
15+
- warnings.filterwarnings("ignore", "Trying to detect", module="charset_normalizer")
1516
-
1617
# This code exists for backwards compatibility reasons.
1718
# I don't like it either. Just look the other way. :)
18-
19-
-for package in ('urllib3', 'idna'):
19+
20+
-for package in ("urllib3", "idna"):
2021
- locals()[package] = __import__(package)
2122
+for package in ('urllib3', 'idna', 'chardet'):
2223
+ vendored_package = "pip._vendor." + package
2324
+ locals()[package] = __import__(vendored_package)
2425
# This traversal is apparently necessary such that the identities are
2526
# preserved (requests.packages.urllib3.* is urllib3.*)
2627
for mod in list(sys.modules):
27-
- if mod == package or mod.startswith(package + '.'):
28-
- sys.modules['requests.packages.' + mod] = sys.modules[mod]
28+
- if mod == package or mod.startswith(f"{package}."):
29+
- sys.modules[f"requests.packages.{mod}"] = sys.modules[mod]
2930
+ if mod == vendored_package or mod.startswith(vendored_package + '.'):
3031
+ unprefixed_mod = mod[len("pip._vendor."):]
3132
+ sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
32-
33+
3334
-target = chardet.__name__
3435
-for mod in list(sys.modules):
35-
- if mod == target or mod.startswith(target + '.'):
36-
- sys.modules['requests.packages.' + target.replace(target, 'chardet')] = sys.modules[mod]
36+
- if mod == target or mod.startswith(f"{target}."):
37+
- target = target.replace(target, "chardet")
38+
- sys.modules[f"requests.packages.{target}"] = sys.modules[mod]
3739
# Kinda cool, though, right?
3840

3941
diff --git a/src/pip/_vendor/requests/__init__.py b/src/pip/_vendor/requests/__init__.py
40-
index 973497f5e..4f80e28fc 100644
42+
index 7ac8e297..1e21e7e4 100644
4143
--- a/src/pip/_vendor/requests/__init__.py
4244
+++ b/src/pip/_vendor/requests/__init__.py
4345
@@ -44,10 +44,7 @@ import urllib3
44-
import warnings
46+
4547
from .exceptions import RequestsDependencyWarning
46-
48+
4749
-try:
4850
- from charset_normalizer import __version__ as charset_normalizer_version
4951
-except ImportError:
5052
- charset_normalizer_version = None
5153
+charset_normalizer_version = None
52-
54+
5355
try:
5456
from chardet import __version__ as chardet_version
55-
@@ -107,6 +104,11 @@ except (AssertionError, ValueError):
57+
@@ -118,6 +115,11 @@ except (AssertionError, ValueError):
5658
# if the standard library doesn't support SNI or the
5759
# 'ssl' library isn't available.
5860
try:
@@ -66,68 +68,58 @@ index 973497f5e..4f80e28fc 100644
6668
except ImportError:
6769

6870
diff --git a/src/pip/_vendor/requests/compat.py b/src/pip/_vendor/requests/compat.py
69-
index 409b7b028..9e2937167 100644
71+
index 6776163c..8ff49e46 100644
7072
--- a/src/pip/_vendor/requests/compat.py
7173
+++ b/src/pip/_vendor/requests/compat.py
72-
@@ -8,10 +8,7 @@ This module handles import compatibility issues between Python 2 and
73-
Python 3.
74+
@@ -7,10 +7,7 @@ between Python 2 and Python 3. It remains for backwards
75+
compatibility until the next major version.
7476
"""
75-
77+
7678
-try:
7779
- import chardet
7880
-except ImportError:
7981
- import charset_normalizer as chardet
8082
+import chardet
81-
83+
8284
import sys
83-
84-
@@ -28,12 +28,14 @@ is_py2 = (_ver[0] == 2)
85+
86+
@@ -27,19 +24,10 @@ is_py2 = _ver[0] == 2
8587
#: Python 3.x?
86-
is_py3 = (_ver[0] == 3)
87-
88+
is_py3 = _ver[0] == 3
89+
90+
-# json/simplejson module import resolution
8891
-has_simplejson = False
8992
-try:
9093
- import simplejson as json
94+
-
9195
- has_simplejson = True
9296
-except ImportError:
9397
- import json
98+
-
99+
-if has_simplejson:
100+
- from simplejson import JSONDecodeError
101+
-else:
102+
- from json import JSONDecodeError
94103
+# Note: We've patched out simplejson support in pip because it prevents
95104
+# upgrading simplejson on Windows.
96-
+# try:
97-
+# import simplejson as json
98-
+# except (ImportError, SyntaxError):
99-
+# # simplejson does not support Python 3.2, it throws a SyntaxError
100-
+# # because of u'...' Unicode literals.
101105
+import json
102-
103-
# ---------
104-
# Specifics
105-
@@ -68,10 +70,7 @@ elif is_py3:
106-
# Keep OrderedDict for backwards compatibility.
107-
from collections import OrderedDict
108-
from collections.abc import Callable, Mapping, MutableMapping
109-
- if has_simplejson:
110-
- from simplejson import JSONDecodeError
111-
- else:
112-
- from json import JSONDecodeError
113-
+ from json import JSONDecodeError
114-
115-
builtin_str = str
116-
str = str
117-
106+
+from json import JSONDecodeError
107+
108+
# Keep OrderedDict for backwards compatibility.
109+
from collections import OrderedDict
118110
diff --git a/src/pip/_vendor/requests/help.py b/src/pip/_vendor/requests/help.py
119-
index 3a843404c..745f0d7b3 100644
111+
index 8fbcd656..c5e9c19e 100644
120112
--- a/src/pip/_vendor/requests/help.py
121113
+++ b/src/pip/_vendor/requests/help.py
122-
@@ -11,10 +11,7 @@ import urllib3
123-
114+
@@ -10,10 +10,7 @@ import urllib3
115+
124116
from . import __version__ as requests_version
125-
117+
126118
-try:
127119
- import charset_normalizer
128120
-except ImportError:
129121
- charset_normalizer = None
130122
+charset_normalizer = None
131-
123+
132124
try:
133125
import chardet

0 commit comments

Comments
 (0)