From 3c1e0efff121129eb42ed26e1d556d5196f08c42 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: 2026年1月13日 14:53:39 +0000 Subject: [PATCH 1/3] Improve compression max_length documentation --- Doc/library/compression.zstd.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/library/compression.zstd.rst b/Doc/library/compression.zstd.rst index 7ca843f27f5e9a..6d99e36e1e5bb6 100644 --- a/Doc/library/compression.zstd.rst +++ b/Doc/library/compression.zstd.rst @@ -331,10 +331,14 @@ Compressing and decompressing data in memory If *max_length* is non-negative, the method returns at most *max_length* bytes of decompressed data. If this limit is reached and further - output can be produced, the :attr:`~.needs_input` attribute will - be set to ``False``. In this case, the next call to + output can be produced (or EOF is reached), the :attr:`~.needs_input` + attribute will be set to ``False``. In this case, the next call to :meth:`~.decompress` may provide *data* as ``b''`` to obtain - more of the output. + more of the output. The full content can thus be read like:: + + process_output(d.decompress(data, max_length)) + while not d.eof and not d.needs_input: + process_output(d.decompress(b"", max_length)) If all of the input data was decompressed and returned (either because this was less than *max_length* bytes, or because From 1b7dad119736c609f6e0a095ccad7dbdd3286acc Mon Sep 17 00:00:00 2001 From: Sam Bull Date: 2026年1月13日 14:57:49 +0000 Subject: [PATCH 2/3] Update zlib.rst --- Doc/library/zlib.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index ce0a22b9456d0b..d626efd73bf25e 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -308,6 +308,11 @@ Decompression objects support the following methods and attributes: :attr:`unconsumed_tail`. This bytestring must be passed to a subsequent call to :meth:`decompress` if decompression is to continue. If *max_length* is zero then the whole input is decompressed, and :attr:`unconsumed_tail` is empty. + For example, the complete body could be read like:: + + process_output(d.decompress(data, max_length)) + while d.unconsumed_tail: + process_output(d.decompress(d.unconsumed_tail, max_length)) .. versionchanged:: 3.6 *max_length* can be used as a keyword argument. From 03addd77e04b35dd9380344ae110c1da285756cd Mon Sep 17 00:00:00 2001 From: Sam Bull Date: 2026年1月13日 14:58:48 +0000 Subject: [PATCH 3/3] Update zlib.rst --- 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 d626efd73bf25e..9818ea9549c184 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -308,7 +308,7 @@ Decompression objects support the following methods and attributes: :attr:`unconsumed_tail`. This bytestring must be passed to a subsequent call to :meth:`decompress` if decompression is to continue. If *max_length* is zero then the whole input is decompressed, and :attr:`unconsumed_tail` is empty. - For example, the complete body could be read like:: + For example, the full content could be read like:: process_output(d.decompress(data, max_length)) while d.unconsumed_tail:

AltStyle によって変換されたページ (->オリジナル) /