summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-01-31 17:19:08 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-01-31 17:19:08 (GMT)
commit2e0b18af3092a24c9689f72af898083ebfd9aec7 (patch)
tree5dd08384e3560210deb41201ae3d7835899b44cd /Doc
parentf7f4517faeec7a37f5ad545092252a55e0450e10 (diff)
downloadcpython-2e0b18af3092a24c9689f72af898083ebfd9aec7.zip
cpython-2e0b18af3092a24c9689f72af898083ebfd9aec7.tar.gz
cpython-2e0b18af3092a24c9689f72af898083ebfd9aec7.tar.bz2
Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative positions are treated as being relative to the end of the input and out of bounds positions result in an IndexError. Also update the PEP and include an explanation of this in the documentation for codecs.register_error. Fixes a small bug in iconv_codecs: if the position from the callback is negative *add* it to the size instead of substracting it. From SF patch #677429.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libcodecs.tex21
-rw-r--r--Doc/lib/libfuncs.tex2
2 files changed, 17 insertions, 6 deletions
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index 355ac5d..caaaaf4 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -103,11 +103,22 @@ Raises a \exception{LookupError} in case the encoding cannot be found.
Register the error handling function \var{error_handler} under the
name \var{name}. \var{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.
+errors parameter.
+
+For encoding \var{error_handler} will be called with a
+\exception{UnicodeEncodeError} instance, which contains information about
+the location of the error. The error handler must either raise this or
+a different exception or return a tuple with a replacement for the
+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.
+
+Decoding and translating works similar, except \exception{UnicodeDecodeError}
+or \exception{UnicodeTranslateError} will be passed to the handler and
+that the replacement from the error handler will be put into the output
+directly.
\end{funcdesc}
\begin{funcdesc}{lookup_error}{name}
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index d5b565f..323a516 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -572,7 +572,7 @@ class C:
\var{classinfo} argument, or of a (direct or indirect) subclass
thereof. Also return true if \var{classinfo} is a type object and
\var{object} is an object of that type. If \var{object} is not a
- class instance or a object of the given type, the function always
+ class instance or an object of the given type, the function always
returns false. If \var{classinfo} is neither a class object nor a
type object, it may be a tuple of class or type objects, or may
recursively contain other such tuples (other sequence types are not