2016-09-02 21:20:30 +00:00
|
|
|
try:
|
|
|
|
import uzlib as zlib
|
2017-02-14 22:56:22 +00:00
|
|
|
import uio as io
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
2017-06-10 17:14:16 +00:00
|
|
|
raise SystemExit
|
2016-09-02 21:20:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Raw DEFLATE bitstream
|
2020-03-23 02:26:08 +00:00
|
|
|
buf = io.BytesIO(b"\xcbH\xcd\xc9\xc9\x07\x00")
|
2016-09-04 11:45:27 +00:00
|
|
|
inp = zlib.DecompIO(buf, -8)
|
2016-09-02 21:20:30 +00: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 11:45:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
# zlib bitstream
|
2020-03-23 02:26:08 +00:00
|
|
|
inp = zlib.DecompIO(io.BytesIO(b"x\x9c30\xa0=\x00\x00\xb3q\x12\xc1"))
|
2016-09-04 11:45:27 +00:00
|
|
|
print(inp.read(10))
|
|
|
|
print(inp.read())
|
|
|
|
|
|
|
|
# zlib bitstream, wrong checksum
|
2020-03-23 02:26:08 +00:00
|
|
|
inp = zlib.DecompIO(io.BytesIO(b"x\x9c30\xa0=\x00\x00\xb3q\x12\xc0"))
|
2016-09-04 11:45:27 +00:00
|
|
|
try:
|
|
|
|
print(inp.read())
|
|
|
|
except OSError as e:
|
|
|
|
print(repr(e))
|