https://github.com/python/cpython/commit/81079d7b1ae9c122ec467d48418eb40bef2ddda3
commit: 81079d7b1ae9c122ec467d48418eb40bef2ddda3
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: malemburg <m...@lemburg.com>
date: 2025-07-27T16:44:25Z
summary:

[3.13] gh-136278: Document codecs.escape_encode() and codecs.escape_decode() 
(GH-136314) (#137150)

gh-136278: Document codecs.escape_encode() and codecs.escape_decode() 
(GH-136314)

Closes GH-136278
(cherry picked from commit 6784ef7da7cbf1a944fd0685630ced54e4a0066c)

Co-authored-by: Toshaksha <147024929+toshak...@users.noreply.github.com>

files:
M Doc/library/codecs.rst

diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index 21c6409ece44c9..8b4b8cef02fac6 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -1472,6 +1472,36 @@ to :class:`bytes` mappings. They are not supported by 
:meth:`bytes.decode`
    Restoration of the aliases for the binary transforms.
 
 
+.. _standalone-codec-functions:
+
+Standalone Codec Functions
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following functions provide encoding and decoding functionality similar to 
codecs,
+but are not available as named codecs through :func:`codecs.encode` or 
:func:`codecs.decode`.
+They are used internally (for example, by :mod:`pickle`) and behave similarly 
to the
+``string_escape`` codec that was removed in Python 3.
+
+.. function:: codecs.escape_encode(input, errors=None)
+
+   Encode *input* using escape sequences. Similar to how :func:`repr` on bytes
+   produces escaped byte values.
+
+   *input* must be a :class:`bytes` object.
+
+   Returns a tuple ``(output, length)`` where *output* is a :class:`bytes`
+   object and *length* is the number of bytes consumed.
+
+.. function:: codecs.escape_decode(input, errors=None)
+
+   Decode *input* from escape sequences back to the original bytes.
+
+   *input* must be a :term:`bytes-like object`.
+
+   Returns a tuple ``(output, length)`` where *output* is a :class:`bytes`
+   object and *length* is the number of bytes consumed.
+
+
 .. _text-transforms:
 
 Text Transforms

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to