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.
This commit is contained in:
Walter Dörwald 2003-01-31 17:19:09 +00:00
parent 84dbf5d022
commit b673f29c07
1 changed files with 4 additions and 0 deletions

View File

@ -104,6 +104,10 @@ Specification
specifies a new position within object, where (after encoding the
replacement) the encoder will continue encoding.
Negative values for newpos are treated as being relative to
end of object. If newpos is out of bounds the encoder will raise
an IndexError.
If the replacement string itself contains an unencodable character
the encoder raises the exception object (but may set a different
reason string before raising).