Description
According to PEP 293, the codec error handling callback should either raise an exception or return a pair (replacement, newpos)
. newpos
specifies a new position within object, where the encoder/decoder will continue encoding/decoding. Negative values for newpos
are treated as being relative to end of object. PEP 293 does not specify the bound of newpos
, and this is a problem.
If newpos == start
, the codec will not advance. If replacement
is empty, it will just hang in an infinite loop, calling the callback again and again. If replacement
is not empty, it will additionally add it in an internal buffer, and finally, after long time, you will get a MemoryError. If newpos < start
, the behavior may be even more weird.
Before fixing other errors in #81000 it even caused a crash, but now it is only an infinite loop.
I propose to limit the returning value by range [start+1, len(object)]
.
Metadata
Metadata
Assignees
Projects
Status