Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Decoding Exhausted Stream #535
Added a "reference" read() test, as well as a demonstration of how it differs from the streaming behavior for deflate or gzip. "reference" may be too strong of word in the context of urllib3, but seems to hold true for the standard library:
>>> from io import BytesIO >>> f = BytesIO('foo') >>> f.read(3) 'foo' >>> f.read() '' >>> f.read() ''
As of this PR opening - I expect 3 existing tests to fail and 1 new test to succeed. No solution yet!
@sigmavirus24 yeah, I'm thinking the errors are intermittent. Can we retest?
WRT the PR - it's a bit different. It's easy to see why the error is raised at the lowest level:
>>> import zlib >>> compress = zlib.compressobj(6, zlib.DEFLATED, 16 + zlib.MAX_WBITS) >>> data = compress.compress(b'foo') >>> data += compress.flush() >>> d = zlib.decompressobj(16 + zlib.MAX_WBITS) >>> d.decompress(data) 'foo' >>> d.decompress(b'') # run all you like... '' >>> d.flush() '' >>> d.decompress(b'') # raises after flush in python 2.7/3.2 - but succeeds in pypy (??) Traceback (most recent call last): File "<stdin>", line 1, in <module> zlib.error: Error -2 while decompressing: inconsistent stream state
It might be "more proper" to track the state of the decompressobj vs. ignoring empty data.