Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c618ae8e
Commit
c618ae8e
authored
May 27, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5784: wbits=0 apparently added in zlib v1.2.3.5
parent
0fdf41d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
Doc/library/zlib.rst
Doc/library/zlib.rst
+1
-0
Lib/test/test_zlib.py
Lib/test/test_zlib.py
+11
-2
No files found.
Doc/library/zlib.rst
View file @
c618ae8e
...
...
@@ -142,6 +142,7 @@ The available exception and functions in this module are:
must include a zlib header and trailer.
* 0: Automatically determine the window size from the zlib header.
Only supported since zlib 1.2.3.5.
* −8 to −15: Uses the absolute value of *wbits* as the window size
logarithm. The input must be a raw stream with no header or trailer.
...
...
Lib/test/test_zlib.py
View file @
c618ae8e
...
...
@@ -681,10 +681,18 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
data
=
None
def
test_wbits
(
self
):
# wbits=0 only supported since zlib v1.2.3.5
# Register "1.2.3" as "1.2.3.0"
v
=
(
zlib
.
ZLIB_RUNTIME_VERSION
+
".0"
).
split
(
"."
,
4
)
supports_wbits_0
=
int
(
v
[
0
])
>
1
or
int
(
v
[
0
])
==
1
\
and
(
int
(
v
[
1
])
>
2
or
int
(
v
[
1
])
==
2
and
(
int
(
v
[
2
])
>
3
or
int
(
v
[
2
])
==
3
and
int
(
v
[
3
])
>=
5
))
co
=
zlib
.
compressobj
(
level
=
1
,
wbits
=
15
)
zlib15
=
co
.
compress
(
HAMLET_SCENE
)
+
co
.
flush
()
self
.
assertEqual
(
zlib
.
decompress
(
zlib15
,
15
),
HAMLET_SCENE
)
self
.
assertEqual
(
zlib
.
decompress
(
zlib15
,
0
),
HAMLET_SCENE
)
if
supports_wbits_0
:
self
.
assertEqual
(
zlib
.
decompress
(
zlib15
,
0
),
HAMLET_SCENE
)
self
.
assertEqual
(
zlib
.
decompress
(
zlib15
,
32
+
15
),
HAMLET_SCENE
)
with
self
.
assertRaisesRegex
(
zlib
.
error
,
'invalid window size'
):
zlib
.
decompress
(
zlib15
,
14
)
...
...
@@ -698,7 +706,8 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
zlib9
=
co
.
compress
(
HAMLET_SCENE
)
+
co
.
flush
()
self
.
assertEqual
(
zlib
.
decompress
(
zlib9
,
9
),
HAMLET_SCENE
)
self
.
assertEqual
(
zlib
.
decompress
(
zlib9
,
15
),
HAMLET_SCENE
)
self
.
assertEqual
(
zlib
.
decompress
(
zlib9
,
0
),
HAMLET_SCENE
)
if
supports_wbits_0
:
self
.
assertEqual
(
zlib
.
decompress
(
zlib9
,
0
),
HAMLET_SCENE
)
self
.
assertEqual
(
zlib
.
decompress
(
zlib9
,
32
+
9
),
HAMLET_SCENE
)
dco
=
zlib
.
decompressobj
(
wbits
=
32
+
9
)
self
.
assertEqual
(
dco
.
decompress
(
zlib9
),
HAMLET_SCENE
)
...
...
Write
Preview
Markdown
is supported
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