]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-53243: Document `codecs.readbuffer_encode()` (#136284)
authorStan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Wed, 9 Jul 2025 07:39:55 +0000 (09:39 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Jul 2025 07:39:55 +0000 (09:39 +0200)
Closes #53243

Doc/library/codecs.rst

index efe211cd2db6c89c660a1df59ff695c9efe0e892..0e84f18dd4d5d54e1edab87e85e9a70ae4801c06 100644 (file)
@@ -265,6 +265,20 @@ 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 <bufferobjects>` or :class:`str`
+   (encoded to UTF-8 before processing), and their length in bytes.
+
+   The *errors* argument is ignored.
+
+   .. 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: