Closed ehan03 closed 2 months ago
I was able to fix this by changing process
to decompress
inside scrapy > utils > _compression.py > _unbrotli
def _unbrotli(data: bytes, *, max_size: int = 0) -> bytes:
decompressor = brotli.Decompressor()
input_stream = BytesIO(data)
output_stream = BytesIO()
output_chunk = b"."
decompressed_size = 0
while output_chunk:
input_chunk = input_stream.read(_CHUNK_SIZE)
output_chunk = decompressor.decompress(input_chunk)
decompressed_size += len(output_chunk)
if max_size and decompressed_size > max_size:
raise _DecompressionMaxSizeExceeded(
f"The number of bytes decompressed so far "
f"({decompressed_size} B) exceed the specified maximum "
f"({max_size} B)."
)
output_stream.write(output_chunk)
output_stream.seek(0)
return output_stream.read()
This seems like a pretty temporary and hacky fix however
Could if be that you are using the deprecated brotlipy
package (no release since 2017) instead of brotli?
Well, do you have brotli
or brotlipy
?
It's weird because I had to make the fix inside of Scrapy's utils as found here
It's not that weird as decompressor
is brotli.Decompressor
.
I have brotli
I just tried a clean reinstall of my env, which has fixed it. Sorry for wasting your time
Improved in #6261
Ah I was using conda
. That makes more sense now
Description
Upon making a POST request using
scrapy.Request
, I get the following error:AttributeError: 'Decompressor' object has no attribute 'process'
The full traceback is as follows:
This only started happening after I upgraded my Scrapy version to the latest release. Reinstalling from scratch did not help either.
Going into the actual file the traceback points to yields this:
Expected behavior: [What you expect to happen]
Previously, I would get no errors and my data would be parsed fine.
Actual behavior: [What actually happens]
AttributeError: 'Decompressor' object has no attribute 'process'
Reproduces how often: [What percentage of the time does it reproduce?]
This occurs every time I start crawling.
Versions