From 9b8bf41afdafd32e95871b0f0c6db827fa47577f Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 9 Oct 2025 11:40:13 +0100 Subject: [PATCH 1/5] Commit --- Doc/library/zlib.rst | 126 +++++++++++++++++++++++++++++++++++++++++-- Doc/tools/.nitignore | 1 - 2 files changed, 121 insertions(+), 6 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index 7c5e9b086e170d..f05bf8324b41aa 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -11,12 +11,12 @@ For applications that require data compression, the functions in this module allow compression and decompression, using the zlib library. The zlib library has its own home page at https://www.zlib.net. There are known incompatibilities between the Python module and versions of the zlib library -earlier than 1.1.3; 1.1.3 has a `security vulnerability `_, so we recommend using -1.1.4 or later. +earlier than 1.1.3; 1.1.3 has a `security vulnerability `_, +so we recommend using 1.1.4 or later. zlib's functions have many options and often need to be used in a particular order. This documentation doesn't attempt to cover all of the permutations; -consult the zlib manual at http://www.zlib.net/manual.html for authoritative +consult the `zlib manual `_ for authoritative information. For reading and writing ``.gz`` files see the :mod:`gzip` module. @@ -340,6 +340,122 @@ Decompression objects support the following methods and attributes: objects. +The following constants are available to configure compression and decompression +behavior: + +.. data:: DEFLATED + + The deflate compression method. + + +.. data:: MAX_WBITS + + The maximum window buffer size. + + +.. data:: DEF_MEM_LEVEL + + The default memory level for compression objects. + + +.. data:: DEF_BUF_SIZE + + The default buffer size for decompression operations. + + +.. data:: Z_NO_COMPRESSION + + Compression level ``0``. + + +.. data:: Z_BEST_SPEED + + Compression level ``1``. + + +.. data:: Z_BEST_COMPRESSION + + Compression level ``9``. + + +.. data:: Z_DEFAULT_COMPRESSION + + Default compression level ``-1``. + + +.. data:: Z_DEFAULT_STRATEGY + + Default compression strategy, for normal data. + + +.. data:: Z_FILTERED + + Compression strategy for data produced by a filter (or predictor). + + +.. data:: Z_HUFFMAN_ONLY + + Compression strategy that forces Huffman coding only. + + +.. data:: Z_RLE + + Compression strategy that limits match distances to one (run-length encoding). + + This constant is only available if Python was compiled with zlib + 1.2.0.1 or greater. + + +.. data:: Z_FIXED + + Compression strategy that prevents the use of dynamic Huffman codes. + + This constant is only available if Python was compiled with zlib + 1.2.2.2 or greater. + + +.. data:: Z_NO_FLUSH + + Flush mode ``0``. No special flushing behavior. + + +.. data:: Z_PARTIAL_FLUSH + + Flush mode ``1``. Flush as much output as possible. + + +.. data:: Z_SYNC_FLUSH + + Flush mode ``2``. All output is flushed and the output is aligned to a byte boundary. + + +.. data:: Z_FULL_FLUSH + + Flush mode ``3``. All output is flushed and the compression state is reset. + + +.. data:: Z_FINISH + + Flush mode ``4``. All pending input is processed, no more input is expected. + + +.. data:: Z_BLOCK + + Flush mode ``5``. A deflate block is completed and emitted. + + This constant is only available if Python was compiled with zlib + 1.2.2.2 or greater. + + +.. data:: Z_TREES + + Flush mode ``6``, for inflate operations. Instructs inflate to return when + it gets to the next deflate block boundary. + + This constant is only available if Python was compiled with zlib + 1.2.3.4 or greater. + + Information about the version of the zlib library in use is available through the following constants: @@ -375,10 +491,10 @@ the following constants: Module :mod:`gzip` Reading and writing :program:`gzip`\ -format files. - http://www.zlib.net + https://www.zlib.net The zlib library home page. - http://www.zlib.net/manual.html + https://www.zlib.net/manual.html The zlib manual explains the semantics and usage of the library's many functions. diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 827c5808fa5865..657d720e766179 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -51,7 +51,6 @@ Doc/library/xml.sax.reader.rst Doc/library/xml.sax.rst Doc/library/xmlrpc.client.rst Doc/library/xmlrpc.server.rst -Doc/library/zlib.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.5.rst Doc/whatsnew/2.6.rst From a1f2afe7ae5558b6db8565357702f7876765c134 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Thu, 9 Oct 2025 13:58:41 +0100 Subject: [PATCH 2/5] unwrap Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/library/zlib.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index f05bf8324b41aa..c0aa1120fc9b3d 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -11,8 +11,8 @@ For applications that require data compression, the functions in this module allow compression and decompression, using the zlib library. The zlib library has its own home page at https://www.zlib.net. There are known incompatibilities between the Python module and versions of the zlib library -earlier than 1.1.3; 1.1.3 has a `security vulnerability `_, -so we recommend using 1.1.4 or later. +earlier than 1.1.3; 1.1.3 has a `security vulnerability `_, so we recommend using +1.1.4 or later. zlib's functions have many options and often need to be used in a particular order. This documentation doesn't attempt to cover all of the permutations; From cace71d2daf01ac268fe0ecc81321c256d8427f8 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 9 Oct 2025 17:11:34 +0100 Subject: [PATCH 3/5] Victor's review --- Doc/library/zlib.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index f05bf8324b41aa..e8c38ee1a0c974 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -367,6 +367,8 @@ behavior: Compression level ``0``. + .. versionadded:: 3.6 + .. data:: Z_BEST_SPEED @@ -380,7 +382,7 @@ behavior: .. data:: Z_DEFAULT_COMPRESSION - Default compression level ``-1``. + Default compression level (``-1``). .. data:: Z_DEFAULT_STRATEGY @@ -405,6 +407,8 @@ behavior: This constant is only available if Python was compiled with zlib 1.2.0.1 or greater. + .. versionadded:: 3.6 + .. data:: Z_FIXED @@ -413,11 +417,15 @@ behavior: This constant is only available if Python was compiled with zlib 1.2.2.2 or greater. + .. versionadded:: 3.6 + .. data:: Z_NO_FLUSH Flush mode ``0``. No special flushing behavior. + .. versionadded:: 3.6 + .. data:: Z_PARTIAL_FLUSH @@ -446,6 +454,8 @@ behavior: This constant is only available if Python was compiled with zlib 1.2.2.2 or greater. + .. versionadded:: 3.6 + .. data:: Z_TREES @@ -455,6 +465,8 @@ behavior: This constant is only available if Python was compiled with zlib 1.2.3.4 or greater. + .. versionadded:: 3.6 + Information about the version of the zlib library in use is available through the following constants: From ca3e8e4fa913cab81d1be05ee90b2bfaf54e7bbe Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 9 Oct 2025 19:05:43 +0100 Subject: [PATCH 4/5] Victor's suggestion --- Doc/library/zlib.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index 3b653f0d77db13..3495d358d2a2cc 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -350,7 +350,7 @@ behavior: .. data:: MAX_WBITS - The maximum window buffer size. + The maximum window buffer size (power of 2). .. data:: DEF_MEM_LEVEL From ffb28d34fabf58d71abb0c2f326fd478f0bea474 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Fri, 10 Oct 2025 16:24:31 +0100 Subject: [PATCH 5/5] Expand MAX_WBITS Co-authored-by: Victor Stinner --- Doc/library/zlib.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index 3495d358d2a2cc..d4727f366d051f 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -350,7 +350,9 @@ behavior: .. data:: MAX_WBITS - The maximum window buffer size (power of 2). + The maximum window size, expressed as a power of 2. + For example, if :const:`!MAX_WBITS` is ``15`` it results in a window size + of ``32 KiB``. .. data:: DEF_MEM_LEVEL