summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libcodecs.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libcodecs.tex')
-rw-r--r--Doc/lib/libcodecs.tex22
1 files changed, 16 insertions, 6 deletions
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index 1806ef0..8a2417e 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -112,6 +112,7 @@ class or factory function.
Raises a \exception{LookupError} in case the encoding cannot be found or the
codec doesn't support an incremental encoder.
+\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{getincrementaldecoder}{encoding}
@@ -120,6 +121,7 @@ class or factory function.
Raises a \exception{LookupError} in case the encoding cannot be found or the
codec doesn't support an incremental decoder.
+\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{getreader}{encoding}
@@ -150,7 +152,7 @@ unencodable part of the input and a position where encoding should
continue. The encoder will encode the replacement and continue encoding
the original input at the specified position. Negative position values
will be treated as being relative to the end of the input string. If the
-resulting position is out of bound an IndexError will be raised.
+resulting position is out of bound an \exception{IndexError} will be raised.
Decoding and translating works similar, except \exception{UnicodeDecodeError}
or \exception{UnicodeTranslateError} will be passed to the handler and
@@ -229,12 +231,14 @@ an encoding error occurs.
Uses an incremental encoder to iteratively encode the input provided by
\var{iterable}. This function is a generator. \var{errors} (as well as
any other keyword argument) is passed through to the incremental encoder.
+\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{iterdecode}{iterable, encoding\optional{, errors}}
Uses an incremental decoder to iteratively decode the input provided by
\var{iterable}. This function is a generator. \var{errors} (as well as
any other keyword argument) is passed through to the incremental encoder.
+\versionadded{2.5}
\end{funcdesc}
The module also provides the following constants which are useful
@@ -355,6 +359,8 @@ encoded/decoded with the stateless encoder/decoder.
\subsubsection{IncrementalEncoder Objects \label{incremental-encoder-objects}}
+\versionadded{2.5}
+
The \class{IncrementalEncoder} class is used for encoding an input in multiple
steps. It defines the following methods which every incremental encoder must
define in order to be compatible to the Python codec registry.
@@ -437,6 +443,10 @@ define in order to be compatible to the Python codec registry.
Decodes \var{object} (taking the current state of the decoder into account)
and returns the resulting decoded object. If this is the last call to
\method{decode} \var{final} must be true (the default is false).
+ If \var{final} is true the decoder must decode the input completely and must
+ flush all buffers. If this isn't possible (e.g. because of incomplete byte
+ sequences at the end of the input) it must initiate error handling just like
+ in the stateless case (which might raise an exception).
\end{methoddesc}
\begin{methoddesc}{reset}{}
@@ -690,10 +700,10 @@ transformation can be done (these methods are also called encodings).
The simplest method is to map the codepoints 0-255 to the bytes
\code{0x0}-\code{0xff}. This means that a unicode object that contains
codepoints above \code{U+00FF} can't be encoded with this method (which
-is called \code{'latin-1'} or \code{'iso-8859-1'}). unicode.encode() will
-raise a UnicodeEncodeError that looks like this: \samp{UnicodeEncodeError:
-'latin-1' codec can't encode character u'\e u1234' in position 3: ordinal
-not in range(256)}.
+is called \code{'latin-1'} or \code{'iso-8859-1'}).
+\function{unicode.encode()} will raise a \exception{UnicodeEncodeError}
+that looks like this: \samp{UnicodeEncodeError: 'latin-1' codec can't
+encode character u'\e u1234' in position 3: ordinal not in range(256)}.
There's another group of encodings (the so called charmap encodings)
that choose a different subset of all unicode code points and how
@@ -1220,7 +1230,7 @@ listed as operand type in the table.
\lineiv{rot_13}
{rot13}
- {byte string}
+ {Unicode string}
{Returns the Caesar-cypher encryption of the operand}
\lineiv{string_escape}