From f6b971075d9530404705f475c8b6572363ca9dee Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 26 Jun 2025 19:33:58 +0100 Subject: [PATCH 1/6] Document --- Doc/library/codecs.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 86511602fa5a60..345e21fa21a8bc 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -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 decoding a custom single-byte encoding. + Given a string *string* of up to 256 characters representing an encoding + table, returns either a compact internal mapping object or a dictionary + 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, /) From 367bdf26f5464aa862647d2d494c79c6965ec752 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 26 Jun 2025 19:43:07 +0100 Subject: [PATCH 2/6] Simplify --- Doc/library/codecs.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 345e21fa21a8bc..20902bcbe52c11 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -57,9 +57,8 @@ any codec: Return a mapping suitable for decoding a custom single-byte encoding. Given a string *string* of up to 256 characters representing an encoding - table, returns either a compact internal mapping object or a dictionary - mapping character ordinals to byte values. Raises a :exc:`TypeError` - on invalid input. + table, returns a dictionary 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: From d748c22005de6212b83e6542bc3aeac871390938 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 30 Jun 2025 13:46:14 +0100 Subject: [PATCH 3/6] Un-simplify --- Doc/library/codecs.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 20902bcbe52c11..db69af5ae2cd91 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -56,8 +56,9 @@ any codec: .. function:: charmap_build(string) Return a mapping suitable for decoding a custom single-byte encoding. - Given a string *string* of up to 256 characters representing an encoding - table, returns a dictionary mapping character ordinals to byte values. + Given a :class:`str` *string* of up to 256 characters representing an + encoding table, returns either a compact internal mapping object or a + dictionary 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: From bc6a2f9bf077e994828269d47c96390d0191a3d7 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 30 Jun 2025 14:07:34 +0100 Subject: [PATCH 4/6] Note name, link dict --- Doc/library/codecs.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index db69af5ae2cd91..5653304b36539f 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -57,8 +57,8 @@ any codec: Return a mapping suitable for decoding a custom single-byte encoding. Given a :class:`str` *string* of up to 256 characters representing an - encoding table, returns either a compact internal mapping object or a - dictionary mapping character ordinals to byte values. + encoding table, returns either a compact internal mapping object + ``EncodingMap`` or a :class:`dictionary ` 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: From fc2a0f7356caee3eac590db3319204d95fa4d82c Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 30 Jun 2025 14:11:55 +0100 Subject: [PATCH 5/6] Wrap text --- Doc/library/codecs.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 5653304b36539f..623fcc5e9c32c6 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -58,8 +58,8 @@ any codec: Return a mapping suitable for decoding a custom single-byte encoding. Given a :class:`str` *string* of up to 256 characters representing an encoding table, returns either a compact internal mapping object - ``EncodingMap`` or a :class:`dictionary ` mapping character ordinals to byte values. - Raises a :exc:`TypeError` on invalid input. + ``EncodingMap`` or a :class:`dictionary ` 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: From 6a1facc6da4120be4ed91d2d275e0b0e5ac9e6d8 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 30 Jun 2025 14:24:53 +0100 Subject: [PATCH 6/6] Switch-up --- Doc/library/codecs.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 623fcc5e9c32c6..b231fa568cf342 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -55,9 +55,9 @@ any codec: .. function:: charmap_build(string) - Return a mapping suitable for decoding a custom single-byte encoding. - Given a :class:`str` *string* of up to 256 characters representing an - encoding table, returns either a compact internal mapping object + 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 ` mapping character ordinals to byte values. Raises a :exc:`TypeError` on invalid input.