Skip to content

Commit 6d290d5

Browse files
Ma Lingpshead
andauthored
[3.10] bpo-47040: improve document of checksum functions (GH-31955) (GH-32002)
Clarifies a versionchanged note on crc32 & adler32 docs that the workaround is only needed for Python 2 and earlier. Also cleans up an unnecessary intermediate variable in the implementation. Authored-By: Ma Lin / animalize Co-authored-by: Gregory P. Smith <[email protected]>
1 parent 906f1a4 commit 6d290d5

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

Doc/library/binascii.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ The :mod:`binascii` module defines the following functions:
135135

136136
.. function:: crc32(data[, value])
137137

138-
Compute CRC-32, the 32-bit checksum of *data*, starting with an
138+
Compute CRC-32, the unsigned 32-bit checksum of *data*, starting with an
139139
initial CRC of *value*. The default initial CRC is zero. The algorithm
140140
is consistent with the ZIP file checksum. Since the algorithm is designed for
141141
use as a checksum algorithm, it is not suitable for use as a general hash
@@ -149,9 +149,8 @@ The :mod:`binascii` module defines the following functions:
149149

150150
.. versionchanged:: 3.0
151151
The result is always unsigned.
152-
To generate the same numeric value across all Python versions and
153-
platforms, use ``crc32(data) & 0xffffffff``.
154-
152+
To generate the same numeric value when using Python 2 or earlier,
153+
use ``crc32(data) & 0xffffffff``.
155154

156155
.. function:: b2a_hex(data[, sep[, bytes_per_sep=1]])
157156
hexlify(data[, sep[, bytes_per_sep=1]])

Doc/library/zlib.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ The available exception and functions in this module are:
4242
for use as a general hash algorithm.
4343

4444
.. versionchanged:: 3.0
45-
Always returns an unsigned value.
46-
To generate the same numeric value across all Python versions and
47-
platforms, use ``adler32(data) & 0xffffffff``.
48-
45+
The result is always unsigned.
46+
To generate the same numeric value when using Python 2 or earlier,
47+
use ``adler32(data) & 0xffffffff``.
4948

5049
.. function:: compress(data, /, level=-1)
5150

@@ -127,10 +126,9 @@ The available exception and functions in this module are:
127126
for use as a general hash algorithm.
128127

129128
.. versionchanged:: 3.0
130-
Always returns an unsigned value.
131-
To generate the same numeric value across all Python versions and
132-
platforms, use ``crc32(data) & 0xffffffff``.
133-
129+
The result is always unsigned.
130+
To generate the same numeric value when using Python 2 or earlier,
131+
use ``crc32(data) & 0xffffffff``.
134132

135133
.. function:: decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
136134

0 commit comments

Comments
 (0)