]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-48181: Document `codecs.charmap_build` (GH-135997) (#136123)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 30 Jun 2025 13:52:46 +0000 (15:52 +0200)
committerGitHub <noreply@github.com>
Mon, 30 Jun 2025 13:52:46 +0000 (15:52 +0200)
gh-48181: Document `codecs.charmap_build` (GH-135997)
(cherry picked from commit 2bdd50309f543f449d7d82b64ed6f60ae0aa80b9)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/library/codecs.rst

index 86511602fa5a60ddf1daad4795c3a97b7824763b..b231fa568cf3423101120647b797c22e324087b7 100644 (file)
@@ -53,6 +53,14 @@ any codec:
    :exc:`UnicodeDecodeError`). Refer to :ref:`codec-base-classes` for more
    information on codec error handling.
 
+.. function:: charmap_build(string)
+
+   Return a mapping suitable for encoding with a custom single-byte encoding.
+   Given a :class:`str` *string* of up to 256 characters representing a
+   decoding table, returns either a compact internal mapping object
+   ``EncodingMap`` or a :class:`dictionary <dict>` mapping character ordinals
+   to byte values. Raises a :exc:`TypeError` on invalid input.
+
 The full details for each codec can also be looked up directly:
 
 .. function:: lookup(encoding, /)