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:
parent
84dbf5d022
commit
b673f29c07
|
@ -104,6 +104,10 @@ Specification
|
||||||
specifies a new position within object, where (after encoding the
|
specifies a new position within object, where (after encoding the
|
||||||
replacement) the encoder will continue encoding.
|
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
|
If the replacement string itself contains an unencodable character
|
||||||
the encoder raises the exception object (but may set a different
|
the encoder raises the exception object (but may set a different
|
||||||
reason string before raising).
|
reason string before raising).
|
||||||
|
|
Loading…
Reference in New Issue