bpo-47040: improve document of checksum functions (gh-31955)

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 <greg@krypto.org>
This commit is contained in:
Ma Lin 2022-03-20 05:42:04 +08:00 committed by GitHub
parent 82e9b0bb0a
commit b3f2d4c8ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 17 deletions

View file

@ -107,7 +107,7 @@ The :mod:`binascii` module defines the following functions:
.. function:: crc32(data[, value])
Compute CRC-32, the 32-bit checksum of *data*, starting with an
Compute CRC-32, the unsigned 32-bit checksum of *data*, starting with an
initial CRC of *value*. The default initial CRC is zero. The algorithm
is consistent with the ZIP file checksum. Since the algorithm is designed for
use as a checksum algorithm, it is not suitable for use as a general hash
@ -121,9 +121,8 @@ The :mod:`binascii` module defines the following functions:
.. versionchanged:: 3.0
The result is always unsigned.
To generate the same numeric value across all Python versions and
platforms, use ``crc32(data) & 0xffffffff``.
To generate the same numeric value when using Python 2 or earlier,
use ``crc32(data) & 0xffffffff``.
.. function:: b2a_hex(data[, sep[, bytes_per_sep=1]])
hexlify(data[, sep[, bytes_per_sep=1]])