From 4e7485cbe81baea1be77c5b04215636153dc95ee Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Fri, 4 Jul 2025 12:56:57 +0100 Subject: [PATCH 1/3] Doc --- Doc/library/codecs.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index b231fa568cf342..d912d64aca1b06 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -265,6 +265,21 @@ wider range of codecs when working with binary files: :func:`iterencode`. +.. function:: readbuffer_encode(buffer, errors=None, /) + + Return a :class:`tuple` containing the raw bytes of *buffer*, a + :ref:`buffer-compatible object ` or :class:`str`, and their + length. + + The *errors* argument is ignored and exists only for compatibility with + other functions. + + .. code-block:: pycon + + >>> codecs.readbuffer_encode(b"Zito") + (b'Zito', 4) + + The module also provides the following constants which are useful for reading and writing to platform dependent files: From 4b65df7f80d398ed4a7f32a7861cfdb32f8c9bd3 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 8 Jul 2025 20:01:04 +0100 Subject: [PATCH 2/3] Victor's review --- Doc/library/codecs.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index d912d64aca1b06..953bdf2a317c8d 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -268,11 +268,10 @@ wider range of codecs when working with binary files: .. function:: readbuffer_encode(buffer, errors=None, /) Return a :class:`tuple` containing the raw bytes of *buffer*, a - :ref:`buffer-compatible object ` or :class:`str`, and their - length. + :ref:`buffer-compatible object ` or :class:`str` + (encoded to UTF-8 before processing), and their length. - The *errors* argument is ignored and exists only for compatibility with - other functions. + The *errors* argument is ignored. .. code-block:: pycon From 78b60d0453ddaed4dd0966e4e947de2a728a3d99 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 9 Jul 2025 08:27:27 +0100 Subject: [PATCH 3/3] Marc's review, already partially addressed by Victor review --- Doc/library/codecs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 953bdf2a317c8d..a527d6746b5d07 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -269,7 +269,7 @@ wider range of codecs when working with binary files: Return a :class:`tuple` containing the raw bytes of *buffer*, a :ref:`buffer-compatible object ` or :class:`str` - (encoded to UTF-8 before processing), and their length. + (encoded to UTF-8 before processing), and their length in bytes. The *errors* argument is ignored.