summaryrefslogtreecommitdiff
path: root/Doc/library/lzma.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/lzma.rst')
-rw-r--r--Doc/library/lzma.rst41
1 files changed, 35 insertions, 6 deletions
diff --git a/Doc/library/lzma.rst b/Doc/library/lzma.rst
index b71051da85..054600530b 100644
--- a/Doc/library/lzma.rst
+++ b/Doc/library/lzma.rst
@@ -110,6 +110,10 @@ Reading and writing compressed files
.. versionchanged:: 3.4
Added support for the ``"x"`` and ``"xb"`` modes.
+ .. versionchanged:: 3.5
+ The :meth:`~io.BufferedIOBase.read` method now accepts an argument of
+ ``None``.
+
Compressing and decompressing data in memory
--------------------------------------------
@@ -221,13 +225,32 @@ Compressing and decompressing data in memory
decompress a multi-stream input with :class:`LZMADecompressor`, you must
create a new decompressor for each stream.
- .. method:: decompress(data)
+ .. method:: decompress(data, max_length=-1)
+
+ Decompress *data* (a :term:`bytes-like object`), returning
+ uncompressed data as bytes. Some of *data* may be buffered
+ internally, for use in later calls to :meth:`decompress`. The
+ returned data should be concatenated with the output of any
+ previous calls to :meth:`decompress`.
+
+ If *max_length* is nonnegative, 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
+ :meth:`~.decompress` may provide *data* as ``b''`` to obtain
+ more of the output.
+
+ If all of the input data was decompressed and returned (either
+ because this was less than *max_length* bytes, or because
+ *max_length* was negative), the :attr:`~.needs_input` attribute
+ will be set to ``True``.
- Decompress *data* (a :class:`bytes` object), returning a :class:`bytes`
- object containing the decompressed data for at least part of the input.
- Some of *data* may be buffered internally, for use in later calls to
- :meth:`decompress`. The returned data should be concatenated with the
- output of any previous calls to :meth:`decompress`.
+ Attempting to decompress data after the end of stream is reached
+ raises an `EOFError`. Any data found after the end of the
+ stream is ignored and saved in the :attr:`~.unused_data` attribute.
+
+ .. versionchanged:: 3.5
+ Added the *max_length* parameter.
.. attribute:: check
@@ -245,6 +268,12 @@ Compressing and decompressing data in memory
Before the end of the stream is reached, this will be ``b""``.
+ .. attribute:: needs_input
+
+ ``False`` if the :meth:`.decompress` method can provide more
+ decompressed data before requiring new uncompressed input.
+
+ .. versionadded:: 3.5
.. function:: compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None)