Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Doc/library/codecs.rst

Issue 18758: Fix internal references in the documentation
Patch Set: Created 6 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/chunk.rst ('k') | Doc/library/code.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`codecs` --- Codec registry and base classes 1 :mod:`codecs` --- Codec registry and base classes
2 ================================================= 2 =================================================
3 3
4 .. module:: codecs 4 .. module:: codecs
5 :synopsis: Encode and decode data and streams. 5 :synopsis: Encode and decode data and streams.
6 .. moduleauthor:: Marc-André Lemburg <mal@lemburg.com> 6 .. moduleauthor:: Marc-André Lemburg <mal@lemburg.com>
7 .. sectionauthor:: Marc-André Lemburg <mal@lemburg.com> 7 .. sectionauthor:: Marc-André Lemburg <mal@lemburg.com>
8 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de> 8 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de>
9 9
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 * ``incrementaldecoder`` An incremental decoder class or factory function; 40 * ``incrementaldecoder`` An incremental decoder class or factory function;
41 41
42 * ``streamwriter`` A stream writer class or factory function; 42 * ``streamwriter`` A stream writer class or factory function;
43 43
44 * ``streamreader`` A stream reader class or factory function. 44 * ``streamreader`` A stream reader class or factory function.
45 45
46 The various functions or classes take the following arguments: 46 The various functions or classes take the following arguments:
47 47
48 *encode* and *decode*: These must be functions or methods which have the same 48 *encode* and *decode*: These must be functions or methods which have the same
49 interface as the :meth:`encode`/:meth:`decode` methods of Codec instances (se e 49 interface as the :meth:`~Codec.encode`/:meth:`~Codec.decode` methods of Codec instances (see
50 Codec Interface). The functions/methods are expected to work in a stateless 50 :ref:`Codec Interface <codec-objects>`). The functions/methods are expected t o work in a stateless
51 mode. 51 mode.
52 52
53 *incrementalencoder* and *incrementaldecoder*: These have to be factory 53 *incrementalencoder* and *incrementaldecoder*: These have to be factory
54 functions providing the following interface: 54 functions providing the following interface:
55 55
56 ``factory(errors='strict')`` 56 ``factory(errors='strict')``
57 57
58 The factory functions must return objects providing the interfaces defined by 58 The factory functions must return objects providing the interfaces defined by
59 the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, 59 the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`,
60 respectively. Incremental codecs can maintain state. 60 respectively. Incremental codecs can maintain state.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 interface and can also be used to easily write your own codecs for use in 307 interface and can also be used to easily write your own codecs for use in
308 Python. 308 Python.
309 309
310 Each codec has to define four interfaces to make it usable as codec in Python: 310 Each codec has to define four interfaces to make it usable as codec in Python:
311 stateless encoder, stateless decoder, stream reader and stream writer. The 311 stateless encoder, stateless decoder, stream reader and stream writer. The
312 stream reader and writers typically reuse the stateless encoder/decoder to 312 stream reader and writers typically reuse the stateless encoder/decoder to
313 implement the file protocols. 313 implement the file protocols.
314 314
315 The :class:`Codec` class defines the interface for stateless encoders/decoders. 315 The :class:`Codec` class defines the interface for stateless encoders/decoders.
316 316
317 To simplify and standardize error handling, the :meth:`encode` and 317 To simplify and standardize error handling, the :meth:`~Codec.encode` and
318 :meth:`decode` methods may implement different error handling schemes by 318 :meth:`~Codec.decode` methods may implement different error handling schemes by
319 providing the *errors* string argument. The following string values are defined 319 providing the *errors* string argument. The following string values are defined
320 and implemented by all standard Python codecs: 320 and implemented by all standard Python codecs:
321 321
322 .. tabularcolumns:: |l|L| 322 .. tabularcolumns:: |l|L|
323 323
324 +-------------------------+-----------------------------------------------+ 324 +-------------------------+-----------------------------------------------+
325 | Value | Meaning | 325 | Value | Meaning |
326 +=========================+===============================================+ 326 +=========================+===============================================+
327 | ``'strict'`` | Raise :exc:`UnicodeError` (or a subclass); | 327 | ``'strict'`` | Raise :exc:`UnicodeError` (or a subclass); |
328 | | this is the default. | 328 | | this is the default. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 The method may not store state in the :class:`Codec` instance. Use 402 The method may not store state in the :class:`Codec` instance. Use
403 :class:`StreamCodec` for codecs which have to keep state in order to make 403 :class:`StreamCodec` for codecs which have to keep state in order to make
404 encoding/decoding efficient. 404 encoding/decoding efficient.
405 405
406 The decoder must be able to handle zero length input and return an empty obje ct 406 The decoder must be able to handle zero length input and return an empty obje ct
407 of the output object type in this situation. 407 of the output object type in this situation.
408 408
409 The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes provide 409 The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes provide
410 the basic interface for incremental encoding and decoding. Encoding/decoding the 410 the basic interface for incremental encoding and decoding. Encoding/decoding the
411 input isn't done with one call to the stateless encoder/decoder function, but 411 input isn't done with one call to the stateless encoder/decoder function, but
412 with multiple calls to the :meth:`encode`/:meth:`decode` method of the 412 with multiple calls to the :meth:`~IncrementalEncoder.encode`/:meth:`~Incrementa lDecoder.decode` method of the
413 incremental encoder/decoder. The incremental encoder/decoder keeps track of the 413 incremental encoder/decoder. The incremental encoder/decoder keeps track of the
414 encoding/decoding process during method calls. 414 encoding/decoding process during method calls.
415 415
416 The joined output of calls to the :meth:`encode`/:meth:`decode` method is the 416 The joined output of calls to the :meth:`~IncrementalEncoder.encode`/:meth:`~Inc rementalDecoder.decode` method is the
417 same as if all the single inputs were joined into one, and this input was 417 same as if all the single inputs were joined into one, and this input was
418 encoded/decoded with the stateless encoder/decoder. 418 encoded/decoded with the stateless encoder/decoder.
419 419
420 420
421 .. _incremental-encoder-objects: 421 .. _incremental-encoder-objects:
422 422
423 IncrementalEncoder Objects 423 IncrementalEncoder Objects
424 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 424 ^^^^^^^^^^^^^^^^^^^^^^^^^^
425 425
426 The :class:`IncrementalEncoder` class is used for encoding an input in multiple 426 The :class:`IncrementalEncoder` class is used for encoding an input in multiple
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 1348
1349 .. module:: encodings.utf_8_sig 1349 .. module:: encodings.utf_8_sig
1350 :synopsis: UTF-8 codec with BOM signature 1350 :synopsis: UTF-8 codec with BOM signature
1351 .. moduleauthor:: Walter Dörwald 1351 .. moduleauthor:: Walter Dörwald
1352 1352
1353 This module implements a variant of the UTF-8 codec: On encoding a UTF-8 encoded 1353 This module implements a variant of the UTF-8 codec: On encoding a UTF-8 encoded
1354 BOM will be prepended to the UTF-8 encoded bytes. For the stateful encoder this 1354 BOM will be prepended to the UTF-8 encoded bytes. For the stateful encoder this
1355 is only done once (on the first write to the byte stream). For decoding an 1355 is only done once (on the first write to the byte stream). For decoding an
1356 optional UTF-8 encoded BOM at the start of the data will be skipped. 1356 optional UTF-8 encoded BOM at the start of the data will be skipped.
1357 1357
OLDNEW
« no previous file with comments | « Doc/library/chunk.rst ('k') | Doc/library/code.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+