1
1
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
3
3
--- a/src/pip/_vendor/requests/packages.py
4
4
+++ b/src/pip/_vendor/requests/packages.py
5
- @@ -1,26 +1,16 @@
5
+ @@ -1,28 +1,16 @@
6
6
import sys
7
-
7
+
8
8
- try:
9
9
- import chardet
10
10
- except ImportError:
11
- - import charset_normalizer as chardet
12
11
- import warnings
13
12
-
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")
15
16
-
16
17
# This code exists for backwards compatibility reasons.
17
18
# 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" ):
20
21
- locals()[package] = __import__(package)
21
22
+ for package in ('urllib3', 'idna', 'chardet'):
22
23
+ vendored_package = "pip._vendor." + package
23
24
+ locals()[package] = __import__(vendored_package)
24
25
# This traversal is apparently necessary such that the identities are
25
26
# preserved (requests.packages.urllib3.* is urllib3.*)
26
27
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]
29
30
+ if mod == vendored_package or mod.startswith(vendored_package + '.'):
30
31
+ unprefixed_mod = mod[len("pip._vendor."):]
31
32
+ sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
32
-
33
+
33
34
- target = chardet.__name__
34
35
- 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]
37
39
# Kinda cool, though, right?
38
40
39
41
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
41
43
--- a/src/pip/_vendor/requests/__init__.py
42
44
+++ b/src/pip/_vendor/requests/__init__.py
43
45
@@ -44,10 +44,7 @@ import urllib3
44
- import warnings
46
+
45
47
from .exceptions import RequestsDependencyWarning
46
-
48
+
47
49
- try:
48
50
- from charset_normalizer import __version__ as charset_normalizer_version
49
51
- except ImportError:
50
52
- charset_normalizer_version = None
51
53
+ charset_normalizer_version = None
52
-
54
+
53
55
try:
54
56
from chardet import __version__ as chardet_version
55
- @@ -107 ,6 +104 ,11 @@ except (AssertionError, ValueError):
57
+ @@ -118 ,6 +115 ,11 @@ except (AssertionError, ValueError):
56
58
# if the standard library doesn't support SNI or the
57
59
# 'ssl' library isn't available.
58
60
try:
@@ -66,68 +68,58 @@ index 973497f5e..4f80e28fc 100644
66
68
except ImportError:
67
69
68
70
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
70
72
--- a/src/pip/_vendor/requests/compat.py
71
73
+++ 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 .
74
76
"""
75
-
77
+
76
78
- try:
77
79
- import chardet
78
80
- except ImportError:
79
81
- import charset_normalizer as chardet
80
82
+ import chardet
81
-
83
+
82
84
import sys
83
-
84
- @@ -28,12 +28,14 @@ is_py2 = ( _ver[0] == 2)
85
+
86
+ @@ -27,19 +24,10 @@ is_py2 = _ver[0] == 2
85
87
#: Python 3.x?
86
- is_py3 = (_ver[0] == 3)
87
-
88
+ is_py3 = _ver[0] == 3
89
+
90
+ - # json/simplejson module import resolution
88
91
- has_simplejson = False
89
92
- try:
90
93
- import simplejson as json
94
+ -
91
95
- has_simplejson = True
92
96
- except ImportError:
93
97
- import json
98
+ -
99
+ - if has_simplejson:
100
+ - from simplejson import JSONDecodeError
101
+ - else:
102
+ - from json import JSONDecodeError
94
103
+ # Note: We've patched out simplejson support in pip because it prevents
95
104
+ # 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.
101
105
+ 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
118
110
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
120
112
--- a/src/pip/_vendor/requests/help.py
121
113
+++ b/src/pip/_vendor/requests/help.py
122
- @@ -11 ,10 +11 ,7 @@ import urllib3
123
-
114
+ @@ -10 ,10 +10 ,7 @@ import urllib3
115
+
124
116
from . import __version__ as requests_version
125
-
117
+
126
118
- try:
127
119
- import charset_normalizer
128
120
- except ImportError:
129
121
- charset_normalizer = None
130
122
+ charset_normalizer = None
131
-
123
+
132
124
try:
133
125
import chardet
0 commit comments