[Python-checkins] [3.10] bpo-47040: improve document of checksum functions (GH-31955) (GH-32002)

gpshead webhook-mailer at python.org
Sun Mar 20 02:57:17 EDT 2022


https://github.com/python/cpython/commit/6d290d5862375799e997f1192ef56abca4e9182e
commit: 6d290d5862375799e997f1192ef56abca4e9182e
branch: 3.10
author: Ma Lin <animalize at users.noreply.github.com>
committer: gpshead <greg at krypto.org>
date: 2022-03-19T23:57:12-07:00
summary:

[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 <greg at krypto.org>

files:
M Doc/library/binascii.rst
M Doc/library/zlib.rst

diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst
index 2c0c1bce5d7f8..5cd058c0b6d74 100644
--- a/Doc/library/binascii.rst
+++ b/Doc/library/binascii.rst
@@ -135,7 +135,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
@@ -149,9 +149,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]])
diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst
index ec60ea24db662..6758c615d74db 100644
--- a/Doc/library/zlib.rst
+++ b/Doc/library/zlib.rst
@@ -42,10 +42,9 @@ The available exception and functions in this module are:
    for use as a general hash algorithm.
 
    .. versionchanged:: 3.0
-      Always returns an unsigned value.
-      To generate the same numeric value across all Python versions and
-      platforms, use ``adler32(data) & 0xffffffff``.
-
+      The result is always unsigned.
+      To generate the same numeric value when using Python 2 or earlier,
+      use ``adler32(data) & 0xffffffff``.
 
 .. function:: compress(data, /, level=-1)
 
@@ -127,10 +126,9 @@ The available exception and functions in this module are:
    for use as a general hash algorithm.
 
    .. versionchanged:: 3.0
-      Always returns an unsigned value.
-      To generate the same numeric value across all Python versions and
-      platforms, use ``crc32(data) & 0xffffffff``.
-
+      The result is always unsigned.
+      To generate the same numeric value when using Python 2 or earlier,
+      use ``crc32(data) & 0xffffffff``.
 
 .. function:: decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
 



More information about the Python-checkins mailing list