@@ -1443,26 +1443,10 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
1443
1443
| uu_codec | uu | Convert the operand using | |
1444
1444
| | | uuencode. | |
1445
1445
+----------------------+------------------+------------------------------+------------------------------+
1446
- | escape_codec | escape | Encode and decode byte | :func: `codecs.escape_encode ` |
1447
- | | | sequences using escape | / |
1448
- | | | sequences, similar to | :func: `codecs.escape_decode ` |
1449
- | | | :func: `repr ` of bytes. | |
1450
- +----------------------+------------------+------------------------------+------------------------------+
1451
1446
| zlib_codec | zip, zlib | Compress the operand using | :meth: `zlib.compress ` / |
1452
1447
| | | gzip. | :meth: `zlib.decompress ` |
1453
1448
+----------------------+------------------+------------------------------+------------------------------+
1454
1449
1455
- .. function :: codecs.escape_encode(input, errors=None)
1456
-
1457
- Encode *input * using escape sequences. Similar to how :func: `repr ` on bytes
1458
- produces escaped byte values. Returns a tuple of the encoded bytes and
1459
- the length consumed.
1460
-
1461
- .. function :: codecs.escape_decode(input, errors=None)
1462
-
1463
- Decode *input * from escape sequences back to the original bytes.
1464
- Returns a tuple of the decoded bytes and the length consumed.
1465
-
1466
1450
.. [#b64 ] In addition to :term: `bytes-like objects <bytes-like object> `,
1467
1451
``'base64_codec' `` also accepts ASCII-only instances of :class: `str ` for
1468
1452
decoding
@@ -1474,6 +1458,36 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
1474
1458
Restoration of the aliases for the binary transforms.
1475
1459
1476
1460
1461
+ .. _standalone-codec-functions :
1462
+
1463
+ Standalone Codec Functions
1464
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
1465
+
1466
+ The following functions provide encoding and decoding functionality similar to codecs,
1467
+ but are not available as named codecs through :func: `codecs.encode ` or :func: `codecs.decode `.
1468
+ They are used internally (for example, by :mod: `pickle `) and behave similarly to the
1469
+ `string_escape ` codec that was removed in Python 3.
1470
+
1471
+ .. function :: codecs.escape_encode(input, errors=None)
1472
+
1473
+ Encode *input * using escape sequences. Similar to how :func: `repr ` on bytes
1474
+ produces escaped byte values.
1475
+
1476
+ *input * must be a :class: `bytes ` object.
1477
+
1478
+ Returns a tuple ``(output, length) `` where *output * is a :class: `bytes `
1479
+ object and *length * is the number of bytes consumed.
1480
+
1481
+ .. function :: codecs.escape_decode(input, errors=None)
1482
+
1483
+ Decode *input * from escape sequences back to the original bytes.
1484
+
1485
+ *input * must be a :term: `bytes-like object `.
1486
+
1487
+ Returns a tuple ``(output, length) `` where *output * is a :class: `bytes `
1488
+ object and *length * is the number of bytes consumed.
1489
+
1490
+
1477
1491
.. _text-transforms :
1478
1492
1479
1493
Text Transforms
0 commit comments