vcrpy
vcrpy copied to clipboard
Incompatible with urllib3 `read(size, decode_content=True)
trafficstars
urllib3 allows the kwargs decode_content=None and cache_content=False.
See: https://urllib3.readthedocs.io/en/stable/reference/urllib3.response.html#urllib3.response.BaseHTTPResponse.read
If trying to patch a library that uses something like:
myresponse.read(decode_content=True) then patching failes with:
Editing VCRHTTPResponse.read as follows fixes the issue:
def read(self, *args, **kwargs):
# urllib3 allows the kwarg 'decode_content' but BytesIO does not support it
kwargs.pop("decode_content", None)
return self._content.read(*args, **kwargs)
I'm not sure if this is the way to go though.