summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libcodecs.tex
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-11-07 22:33:17 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-11-07 22:33:17 (GMT)
commit430b1563dde73ae1dc8f2379bdd29a0b0e5c82eb (patch)
tree5461f9555be3cb2a3b5da5391794424ce993f067 /Doc/lib/libcodecs.tex
parentb5f41dedeb7a631acd96896698719da08f94b26c (diff)
downloadcpython-430b1563dde73ae1dc8f2379bdd29a0b0e5c82eb.zip
cpython-430b1563dde73ae1dc8f2379bdd29a0b0e5c82eb.tar.gz
cpython-430b1563dde73ae1dc8f2379bdd29a0b0e5c82eb.tar.bz2
Add documentation for the PEP 293 functionality:
The errors attribute can be changed after the reader/writer is created. For encoding there are two additional errors values: "xmlcharrefreplace" and "backslashreplace". These values can be extended via register_error().
Diffstat (limited to 'Doc/lib/libcodecs.tex')
-rw-r--r--Doc/lib/libcodecs.tex32
1 files changed, 29 insertions, 3 deletions
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index d435440..121183b 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -227,14 +227,21 @@ string values are defined and implemented by all standard Python
codecs:
\begin{tableii}{l|l}{code}{Value}{Meaning}
- \lineii{'strict'}{Raise \exception{ValueError} (or a subclass);
+ \lineii{'strict'}{Raise \exception{UnicodeError} (or a subclass);
this is the default.}
\lineii{'ignore'}{Ignore the character and continue with the next.}
\lineii{'replace'}{Replace with a suitable replacement character;
Python will use the official U+FFFD REPLACEMENT
- CHARACTER for the built-in Unicode codecs.}
+ CHARACTER for the built-in Unicode codecs on
+ decoding and '?' on encoding.}
+ \lineii{'xmlcharrefreplace'}{Replace with the appropriate XML
+ character reference (only for encoding).}
+ \lineii{'backslashreplace'}{Replace with backslashed escape sequences
+ (only for encoding).}
\end{tableii}
+The set of allowed values can be extended via \method{register_error}.
+
\subsubsection{Codec Objects \label{codec-objects}}
@@ -303,14 +310,25 @@ order to be compatible to the Python codec registry.
The \class{StreamWriter} may implement different error handling
schemes by providing the \var{errors} keyword argument. These
- parameters are defined:
+ parameters are predefined:
\begin{itemize}
\item \code{'strict'} Raise \exception{ValueError} (or a subclass);
this is the default.
\item \code{'ignore'} Ignore the character and continue with the next.
\item \code{'replace'} Replace with a suitable replacement character
+ \item \code{'xmlcharrefreplace'} Replace with the appropriate XML
+ character reference
+ \item \code{'backslashreplace'} Replace with backslashed escape sequences.
\end{itemize}
+
+ The \var{errors} argument will be assigned to an attribute of the
+ same name. Assigning to this attribute makes it possible to switch
+ between different error handling strategies during the lifetime
+ of the \class{StreamWriter} object.
+
+ The set of allowed values for the \var{errors} argument can
+ be extended with \function{register_error()}.
\end{classdesc}
\begin{methoddesc}{write}{object}
@@ -360,6 +378,14 @@ order to be compatible to the Python codec registry.
\item \code{'ignore'} Ignore the character and continue with the next.
\item \code{'replace'} Replace with a suitable replacement character.
\end{itemize}
+
+ The \var{errors} argument will be assigned to an attribute of the
+ same name. Assigning to this attribute makes it possible to switch
+ between different error handling strategies during the lifetime
+ of the \class{StreamReader} object.
+
+ The set of allowed values for the \var{errors} argument can
+ be extended with \function{register_error()}.
\end{classdesc}
\begin{methoddesc}{read}{\optional{size}}