Skip to content

Commit 8f99623

Browse files
committed
Work around cachecontrol incompatibility
1 parent 6fa8356 commit 8f99623

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/pip/_vendor/cachecontrol/serialize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def dumps(self, request, response, body=None):
5151
u"status": response.status,
5252
u"version": response.version,
5353
u"reason": text_type(response.reason),
54-
u"strict": response.strict,
54+
u"strict": True,
5555
u"decode_content": response.decode_content,
5656
}
5757
}
@@ -137,7 +137,9 @@ def prepare_response(self, request, cached, body_file=None):
137137
#
138138
# TypeError: 'str' does not support the buffer interface
139139
body = io.BytesIO(body_raw.encode("utf8"))
140-
140+
# Work around ionrock/cachecontrol#292. According to urllib3 maintainers,
141+
# the 'strict' argument can be simply dropped since we always use urllib3 2.x.
142+
cached["response"].pop("strict", None)
141143
return HTTPResponse(body=body, preload_content=False, **cached["response"])
142144

143145
def _loads_v0(self, request, data, body_file=None):
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/src/pip/_vendor/cachecontrol/serialize.py b/src/pip/_vendor/cachecontrol/serialize.py
2+
index 7fe1a3e33..9a4859912 100644
3+
--- a/src/pip/_vendor/cachecontrol/serialize.py
4+
+++ b/src/pip/_vendor/cachecontrol/serialize.py
5+
@@ -51,7 +51,7 @@ class Serializer(object):
6+
u"status": response.status,
7+
u"version": response.version,
8+
u"reason": text_type(response.reason),
9+
- u"strict": response.strict,
10+
+ u"strict": True,
11+
u"decode_content": response.decode_content,
12+
}
13+
}
14+
@@ -137,7 +137,9 @@ class Serializer(object):
15+
#
16+
# TypeError: 'str' does not support the buffer interface
17+
body = io.BytesIO(body_raw.encode("utf8"))
18+
-
19+
+ # Work around ionrock/cachecontrol#292. According to urllib3 maintainers,
20+
+ # the 'strict' argument can be simply dropped since we always use urllib3 2.x.
21+
+ cached["response"].pop("strict", None)
22+
return HTTPResponse(body=body, preload_content=False, **cached["response"])
23+
24+
def _loads_v0(self, request, data, body_file=None):

0 commit comments

Comments
 (0)