Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
2324f3ef
Commit
2324f3ef
authored
Jan 28, 2015
by
Paul Sokolovsky
Browse files
moduzlib: Implement raw DEFLATE decoding support.
parent
0b3014ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
extmod/moduzlib.c
View file @
2324f3ef
...
...
@@ -68,7 +68,12 @@ STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
decomp
->
destGrow
=
mod_uzlib_grow_buf
;
decomp
->
source
=
bufinfo
.
buf
;
int
st
=
tinf_zlib_uncompress_dyn
(
decomp
,
bufinfo
.
len
);
int
st
;
if
(
n_args
>
1
&&
MP_OBJ_SMALL_INT_VALUE
(
args
[
1
])
<
0
)
{
st
=
tinf_uncompress_dyn
(
decomp
);
}
else
{
st
=
tinf_zlib_uncompress_dyn
(
decomp
,
bufinfo
.
len
);
}
if
(
st
!=
0
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_ValueError
,
MP_OBJ_NEW_SMALL_INT
(
st
)));
}
...
...
tests/extmod/zlibd_decompress.py
View file @
2324f3ef
...
...
@@ -14,3 +14,11 @@ PATTERNS = [
for
unpacked
,
packed
in
PATTERNS
:
assert
zlib
.
decompress
(
packed
)
==
unpacked
print
(
unpacked
)
# Raw DEFLATE bitstream
v
=
b
'
\xcb
H
\xcd\xc9\xc9\x07\x00\x86\xa6\x10
6
\x05\x00\x00\x00
'
exp
=
b
"hello"
out
=
zlib
.
decompress
(
v
,
-
15
)
assert
(
out
==
exp
)
print
(
exp
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment