diff options
author | Walter Dörwald <walter@livinglogic.de> | 2002-09-02 13:14:32 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2002-09-02 13:14:32 (GMT) |
commit | 3aeb632c3152fa082132ce55b9a880e0d16b04ae (patch) | |
tree | 192bc1543ea77a826d0c940d024dbc8ebba82156 /Doc/lib | |
parent | 94fab762de532de551987e1f48a125145f85304b (diff) | |
download | cpython-3aeb632c3152fa082132ce55b9a880e0d16b04ae.zip cpython-3aeb632c3152fa082132ce55b9a880e0d16b04ae.tar.gz cpython-3aeb632c3152fa082132ce55b9a880e0d16b04ae.tar.bz2 |
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libcodecs.tex | 39 | ||||
-rw-r--r-- | Doc/lib/libexcs.tex | 21 |
2 files changed, 59 insertions, 1 deletions
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex index 136c528..85ca7a5 100644 --- a/Doc/lib/libcodecs.tex +++ b/Doc/lib/libcodecs.tex @@ -17,7 +17,7 @@ This module defines base classes for standard Python codecs (encoders and decoders) and provides access to the internal Python codec -registry which manages the codec lookup process. +registry which manages the codec and error handling lookup process. It defines the following functions: @@ -98,6 +98,43 @@ Raises a \exception{LookupError} in case the encoding cannot be found. To simplify working with encoded files or stream, the module also defines these utility functions: +\begin{funcdesc}{register_error}{name, error_handler} +Register the error handling function \var{error_handler} under the +name \var{name}. \vari{error_handler} will be called during encoding +and decoding in case of an error, when \var{name} is specified as the +errors parameter. \var{error_handler} will be called with an +\exception{UnicodeEncodeError}, \exception{UnicodeDecodeError} or +\exception{UnicodeTranslateError} instance and must return a tuple +with a replacement for the unencodable/undecodable part of the input +and a position where encoding/decoding should continue. +\end{funcdesc} + +\begin{funcdesc}{lookup_error}{name} +Return the error handler previously register under the name \var{name}. + +Raises a \exception{LookupError} in case the handler cannot be found. +\end{funcdesc} + +\begin{funcdesc}{strict_errors}{exception} +Implements the \code{strict} error handling. +\end{funcdesc} + +\begin{funcdesc}{replace_errors}{exception} +Implements the \code{replace} error handling. +\end{funcdesc} + +\begin{funcdesc}{ignore_errors}{exception} +Implements the \code{ignore} error handling. +\end{funcdesc} + +\begin{funcdesc}{xmlcharrefreplace_errors_errors}{exception} +Implements the \code{xmlcharrefreplace} error handling. +\end{funcdesc} + +\begin{funcdesc}{backslashreplace_errors_errors}{exception} +Implements the \code{backslashreplace} error handling. +\end{funcdesc} + \begin{funcdesc}{open}{filename, mode\optional{, encoding\optional{, errors\optional{, buffering}}}} Open an encoded file using the given \var{mode} and return diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex index 078fe3c..54b141a 100644 --- a/Doc/lib/libexcs.tex +++ b/Doc/lib/libexcs.tex @@ -335,6 +335,24 @@ Raised when an \keyword{assert} statement fails. \versionadded{2.0} \end{excdesc} +\begin{excdesc}{UnicodeEncodeError} + Raised when a Unicode-related error occurs during encoding. It + is a subclass of \exception{UnicodeError}. +\versionadded{2.3} +\end{excdesc} + +\begin{excdesc}{UnicodeDecodeError} + Raised when a Unicode-related error occurs during decoding. It + is a subclass of \exception{UnicodeError}. +\versionadded{2.3} +\end{excdesc} + +\begin{excdesc}{UnicodeTranslateError} + Raised when a Unicode-related error occurs during translating. It + is a subclass of \exception{UnicodeError}. +\versionadded{2.3} +\end{excdesc} + \begin{excdesc}{ValueError} Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the @@ -426,6 +444,9 @@ The class hierarchy for built-in exceptions is: | | +-- FloatingPointError | +-- ValueError | | +-- UnicodeError + | | +-- UnicodeEncodeError + | | +-- UnicodeDecodeError + | | +-- UnicodeTranslateError | +-- ReferenceError | +-- SystemError | +-- MemoryError |