2016-09-03 00:20:30 +03:00
|
|
|
try:
|
2022-08-18 16:57:45 +10:00
|
|
|
import zlib
|
|
|
|
import io
|
2017-02-15 01:56:22 +03:00
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
2017-06-10 20:14:16 +03:00
|
|
|
raise SystemExit
|
2016-09-03 00:20:30 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Raw DEFLATE bitstream
|
|
|
|
buf = io.BytesIO(b"\xcbH\xcd\xc9\xc9\x07\x00")
|
2016-09-04 14:45:27 +03:00
|
|
|
inp = zlib.DecompIO(buf, -8)
|
2016-09-03 00:20:30 +03:00
|
|
|
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))
|
2016-09-04 14:45:27 +03:00
|
|
|
|
|
|
|
|
2023-02-09 15:20:25 +11:00
|
|
|
# zlib bitstream (with 256 byte window size)
|
|
|
|
inp = zlib.DecompIO(io.BytesIO(b"\x08\x9930\xa0=\x00\x00\xb3q\x12\xc1"))
|
2016-09-04 14:45:27 +03:00
|
|
|
print(inp.read(10))
|
|
|
|
print(inp.read())
|
|
|
|
|
|
|
|
# zlib bitstream, wrong checksum
|
2023-02-09 15:20:25 +11:00
|
|
|
inp = zlib.DecompIO(io.BytesIO(b"\x08\x9930\xa0=\x00\x00\xb3q\x12\xc0"))
|
2016-09-04 14:45:27 +03:00
|
|
|
try:
|
|
|
|
print(inp.read())
|
|
|
|
except OSError as e:
|
|
|
|
print(repr(e))
|