Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ad934f

Browse files
committed
zlib only works with bytes objects.
1 parent 2997837 commit 4ad934f

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

Doc/library/zlib.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ The available exception and functions in this module are:
5151
regardless of sign.
5252

5353

54-
.. function:: compress(string[, level])
54+
.. function:: compress(data[, level])
5555

56-
Compresses the data in *string*, returning a string contained compressed data.
56+
Compresses the bytes in *data*, returning a bytes object containing compressed data.
5757
*level* is an integer from ``1`` to ``9`` controlling the level of compression;
5858
``1`` is fastest and produces the least compression, ``9`` is slowest and
5959
produces the most. The default value is ``6``. Raises the :exc:`error`
@@ -92,9 +92,9 @@ The available exception and functions in this module are:
9292
regardless of sign.
9393

9494

95-
.. function:: decompress(string[, wbits[, bufsize]])
95+
.. function:: decompress(data[, wbits[, bufsize]])
9696

97-
Decompresses the data in *string*, returning a string containing the
97+
Decompresses the bytes in *data*, returning a bytes object containing the
9898
uncompressed data. The *wbits* parameter controls the size of the window
9999
buffer, and is discussed further below.
100100
If *bufsize* is given, it is used as the initial size of the output
@@ -125,21 +125,21 @@ The available exception and functions in this module are:
125125
Compression objects support the following methods:
126126

127127

128-
.. method:: Compress.compress(string)
128+
.. method:: Compress.compress(data)
129129

130-
Compress *string*, returning a string containing compressed data for at least
131-
part of the data in *string*. This data should be concatenated to the output
130+
Compress *data*, returning a bytes object containing compressed data for at least
131+
part of the data in *data*. This data should be concatenated to the output
132132
produced by any preceding calls to the :meth:`compress` method. Some input may
133133
be kept in internal buffers for later processing.
134134

135135

136136
.. method:: Compress.flush([mode])
137137

138-
All pending input is processed, and a string containing the remaining compressed
138+
All pending input is processed, and a bytes object containing the remaining compressed
139139
output is returned. *mode* can be selected from the constants
140140
:const:`Z_SYNC_FLUSH`, :const:`Z_FULL_FLUSH`, or :const:`Z_FINISH`,
141141
defaulting to :const:`Z_FINISH`. :const:`Z_SYNC_FLUSH` and
142-
:const:`Z_FULL_FLUSH` allow compressing further strings of data, while
142+
:const:`Z_FULL_FLUSH` allow compressing further bytestrings of data, while
143143
:const:`Z_FINISH` finishes the compressed stream and prevents compressing any
144144
more data. After calling :meth:`flush` with *mode* set to :const:`Z_FINISH`,
145145
the :meth:`compress` method cannot be called again; the only realistic action is
@@ -157,31 +157,31 @@ Decompression objects support the following methods, and two attributes:
157157

158158
.. attribute:: Decompress.unused_data
159159

160-
A string which contains any bytes past the end of the compressed data. That is,
160+
A bytes object which contains any bytes past the end of the compressed data. That is,
161161
this remains ``""`` until the last byte that contains compression data is
162-
available. If the whole string turned out to contain compressed data, this is
163-
``""``, the empty string.
162+
available. If the whole bytestring turned out to contain compressed data, this is
163+
``b""``, an empty bytes object.
164164

165-
The only way to determine where a string of compressed data ends is by actually
165+
The only way to determine where a bytestring of compressed data ends is by actually
166166
decompressing it. This means that when compressed data is contained part of a
167167
larger file, you can only find the end of it by reading data and feeding it
168-
followed by some non-empty string into a decompression object's
168+
followed by some non-empty bytestring into a decompression object's
169169
:meth:`decompress` method until the :attr:`unused_data` attribute is no longer
170-
the empty string.
170+
empty.
171171

172172

173173
.. attribute:: Decompress.unconsumed_tail
174174

175-
A string that contains any data that was not consumed by the last
175+
A bytes object that contains any data that was not consumed by the last
176176
:meth:`decompress` call because it exceeded the limit for the uncompressed data
177177
buffer. This data has not yet been seen by the zlib machinery, so you must feed
178178
it (possibly with further data concatenated to it) back to a subsequent
179179
:meth:`decompress` method call in order to get correct output.
180180

181181

182-
.. method:: Decompress.decompress(string[, max_length])
182+
.. method:: Decompress.decompress(data[, max_length])
183183

184-
Decompress *string*, returning a string containing the uncompressed data
184+
Decompress *data*, returning a bytes object containing the uncompressed data
185185
corresponding to at least part of the data in *string*. This data should be
186186
concatenated to the output produced by any preceding calls to the
187187
:meth:`decompress` method. Some of the input data may be preserved in internal
@@ -190,15 +190,15 @@ Decompression objects support the following methods, and two attributes:
190190
If the optional parameter *max_length* is supplied then the return value will be
191191
no longer than *max_length*. This may mean that not all of the compressed input
192192
can be processed; and unconsumed data will be stored in the attribute
193-
:attr:`unconsumed_tail`. This string must be passed to a subsequent call to
193+
:attr:`unconsumed_tail`. This bytestring must be passed to a subsequent call to
194194
:meth:`decompress` if decompression is to continue. If *max_length* is not
195-
supplied then the whole input is decompressed, and :attr:`unconsumed_tail` is an
196-
empty string.
195+
supplied then the whole input is decompressed, and :attr:`unconsumed_tail` is
196+
empty.
197197

198198

199199
.. method:: Decompress.flush([length])
200200

201-
All pending input is processed, and a string containing the remaining
201+
All pending input is processed, and a bytes object containing the remaining
202202
uncompressed output is returned. After calling :meth:`flush`, the
203203
:meth:`decompress` method cannot be called again; the only realistic action is
204204
to delete the object.

0 commit comments

Comments
 (0)