@@ -520,44 +520,46 @@ The base :class:`Codec` class defines these methods which also define the
520520function interfaces of the stateless encoder and decoder:
521521
522522
523- .. method :: Codec.encode(input, errors='strict')
523+ .. class :: Codec
524524
525- Encodes the object *input * and returns a tuple (output object, length consumed).
526- For instance, :term: `text encoding ` converts
527- a string object to a bytes object using a particular
528- character set encoding (e.g., ``cp1252 `` or ``iso-8859-1 ``).
525+ .. method :: encode(input, errors='strict')
529526
530- The *errors * argument defines the error handling to apply.
531- It defaults to ``'strict' `` handling.
527+ Encodes the object *input * and returns a tuple (output object, length consumed).
528+ For instance, :term: `text encoding ` converts
529+ a string object to a bytes object using a particular
530+ character set encoding (e.g., ``cp1252 `` or ``iso-8859-1 ``).
532531
533- The method may not store state in the :class: `Codec ` instance. Use
534- :class: `StreamWriter ` for codecs which have to keep state in order to make
535- encoding efficient.
532+ The *errors * argument defines the error handling to apply.
533+ It defaults to ``'strict' `` handling.
536534
537- The encoder must be able to handle zero length input and return an empty object
538- of the output object type in this situation.
535+ The method may not store state in the :class: `Codec ` instance. Use
536+ :class: `StreamWriter ` for codecs which have to keep state in order to make
537+ encoding efficient.
539538
539+ The encoder must be able to handle zero length input and return an empty object
540+ of the output object type in this situation.
540541
541- .. method :: Codec.decode(input, errors='strict')
542542
543- Decodes the object *input * and returns a tuple (output object, length
544- consumed). For instance, for a :term: `text encoding `, decoding converts
545- a bytes object encoded using a particular
546- character set encoding to a string object.
543+ .. method :: decode(input, errors='strict')
547544
548- For text encodings and bytes-to-bytes codecs,
549- *input * must be a bytes object or one which provides the read-only
550- buffer interface -- for example, buffer objects and memory mapped files.
545+ Decodes the object *input * and returns a tuple (output object, length
546+ consumed). For instance, for a :term: `text encoding `, decoding converts
547+ a bytes object encoded using a particular
548+ character set encoding to a string object.
551549
552- The *errors * argument defines the error handling to apply.
553- It defaults to ``'strict' `` handling.
550+ For text encodings and bytes-to-bytes codecs,
551+ *input * must be a bytes object or one which provides the read-only
552+ buffer interface -- for example, buffer objects and memory mapped files.
554553
555- The method may not store state in the :class: `Codec ` instance. Use
556- :class: `StreamReader ` for codecs which have to keep state in order to make
557- decoding efficient.
554+ The *errors * argument defines the error handling to apply.
555+ It defaults to ``'strict' `` handling.
558556
559- The decoder must be able to handle zero length input and return an empty object
560- of the output object type in this situation.
557+ The method may not store state in the :class: `Codec ` instance. Use
558+ :class: `StreamReader ` for codecs which have to keep state in order to make
559+ decoding efficient.
560+
561+ The decoder must be able to handle zero length input and return an empty object
562+ of the output object type in this situation.
561563
562564
563565Incremental Encoding and Decoding
@@ -705,7 +707,7 @@ Stream Encoding and Decoding
705707
706708The :class: `StreamWriter ` and :class: `StreamReader ` classes provide generic
707709working interfaces which can be used to implement new encoding submodules very
708- easily. See :mod: `encodings.utf_8 ` for an example of how this is done.
710+ easily. See :mod: `! encodings.utf_8 ` for an example of how this is done.
709711
710712
711713.. _stream-writer-objects :
@@ -895,9 +897,10 @@ The design is such that one can use the factory functions returned by the
895897.. class :: StreamRecoder(stream, encode, decode, Reader, Writer, errors='strict')
896898
897899 Creates a :class: `StreamRecoder ` instance which implements a two-way conversion:
898- *encode * and *decode * work on the frontend — the data visible to
899- code calling :meth: `read ` and :meth: `write `, while *Reader * and *Writer *
900- work on the backend — the data in *stream *.
900+ *encode * and *decode * work on the frontend — the data visible to
901+ code calling :meth: `~StreamReader.read ` and :meth: `~StreamWriter.write `,
902+ while *Reader * and *Writer *
903+ work on the backend — the data in *stream *.
901904
902905 You can use these objects to do transparent transcodings, e.g., from Latin-1
903906 to UTF-8 and back.
@@ -1417,8 +1420,8 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
14171420| | quotedprintable, | quoted printable. | ``quotetabs=True `` / |
14181421| | quoted_printable | | :meth: `quopri.decode ` |
14191422+----------------------+------------------+------------------------------+------------------------------+
1420- | uu_codec | uu | Convert the operand using | :meth: ` uu.encode ` / |
1421- | | | uuencode. | :meth: ` uu.decode ` |
1423+ | uu_codec | uu | Convert the operand using | |
1424+ | | | uuencode. | |
14221425+----------------------+------------------+------------------------------+------------------------------+
14231426| zlib_codec | zip, zlib | Compress the operand using | :meth: `zlib.compress ` / |
14241427| | | gzip. | :meth: `zlib.decompress ` |
0 commit comments