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