From 240dc16a2091d988d6fbc2767ded16806fb2f084 Mon Sep 17 00:00:00 2001 From: Jeff Dairiki Date: Tue, 23 May 2023 21:21:36 -0700 Subject: [PATCH] fix: omit `strict` attribute during response deserialization This prevents issues when deserializing responses serialized by an earlier version of cachecontrol. --- cachecontrol/serialize.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cachecontrol/serialize.py b/cachecontrol/serialize.py index f0c215c..738fac7 100644 --- a/cachecontrol/serialize.py +++ b/cachecontrol/serialize.py @@ -137,6 +137,9 @@ def prepare_response(self, request, cached, body_file=None): # TypeError: 'str' does not support the buffer interface body = io.BytesIO(body_raw.encode("utf8")) + # Discard any `strict` parameter serialized by older version of cachecontrol. + cached["response"].pop("strict", None) + return HTTPResponse(body=body, preload_content=False, **cached["response"]) def _loads_v0(self, request, data, body_file=None):