diff options
author | Raymond Hettinger <python@rcn.com> | 2015-09-08 00:36:56 -0400 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-09-08 00:36:56 -0400 |
commit | 6a97f4d4add4a048b03db0576a3da6522a02e176 (patch) | |
tree | a0eb3c2cf7546b895a6f47b5e6b9404a6cc45b62 /Doc/library/bz2.rst | |
parent | ba1b338c7060bb018ad015964d7da94621fc18ca (diff) | |
parent | a505c27518b3bc7e2c088dd7d4db802956e1155d (diff) | |
download | cpython-6a97f4d4add4a048b03db0576a3da6522a02e176.tar.gz |
merge
Diffstat (limited to 'Doc/library/bz2.rst')
-rw-r--r-- | Doc/library/bz2.rst | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index 488cda5968..1b8d9cffc6 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -120,6 +120,10 @@ All of the classes in this module may safely be accessed from multiple threads. .. versionchanged:: 3.4 The ``'x'`` (exclusive creation) mode was added. + .. versionchanged:: 3.5 + The :meth:`~io.BufferedIOBase.read` method now accepts an argument of + ``None``. + Incremental (de)compression --------------------------- @@ -162,15 +166,32 @@ Incremental (de)compression you need to decompress a multi-stream input with :class:`BZ2Decompressor`, you must use 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. - Provide data to the decompressor object. Returns a chunk of decompressed - data if possible, or an empty byte string otherwise. + 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``. - Attempting to decompress data after the end of the current stream is - reached raises an :exc:`EOFError`. If any data is found after the end of - the stream, it is ignored and saved in the :attr:`unused_data` attribute. + 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:: eof @@ -186,6 +207,13 @@ Incremental (de)compression If this attribute is accessed before the end of the stream has been reached, its value 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 + One-shot (de)compression ------------------------ |