b1123a54c1
By changing the zlib header so that it uses a small (256 byte) window. Signed-off-by: Damien George <damien@micropython.org>
34 lines
725 B
Python
34 lines
725 B
Python
try:
|
|
import uzlib as zlib
|
|
import uio as io
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
|
|
# Raw DEFLATE bitstream
|
|
buf = io.BytesIO(b"\xcbH\xcd\xc9\xc9\x07\x00")
|
|
inp = zlib.DecompIO(buf, -8)
|
|
print(buf.seek(0, 1))
|
|
print(inp.read(1))
|
|
print(buf.seek(0, 1))
|
|
print(inp.read(2))
|
|
print(inp.read())
|
|
print(buf.seek(0, 1))
|
|
print(inp.read(1))
|
|
print(inp.read())
|
|
print(buf.seek(0, 1))
|
|
|
|
|
|
# zlib bitstream (with 256 byte window size)
|
|
inp = zlib.DecompIO(io.BytesIO(b"\x08\x9930\xa0=\x00\x00\xb3q\x12\xc1"))
|
|
print(inp.read(10))
|
|
print(inp.read())
|
|
|
|
# zlib bitstream, wrong checksum
|
|
inp = zlib.DecompIO(io.BytesIO(b"\x08\x9930\xa0=\x00\x00\xb3q\x12\xc0"))
|
|
try:
|
|
print(inp.read())
|
|
except OSError as e:
|
|
print(repr(e))
|