[issue36819] Crash during encoding using UTF-16/32 and custom error handler

STINNER Victor report at bugs.python.org
Wed Sep 29 03:35:23 EDT 2021


STINNER Victor <vstinner at python.org> added the comment:

> We could just forbid error handlers returning position not in the range (start , end]

Yeah, that sounds like a reasonable solution. I don't see the point of returning a position outside this range. What would be the use case?

For me, the only corner case is the "ignore" error handler which returns an empty string, but it returns a position in this range, no?

> it can break some code, so it is better to do this only in a new release.

Implementing custom error handlers is a rare use case, so it should only affect a minority of users. Moreover, IMO returning a position outside the valid range is a bug. It's common that security fixes change the behavior, like rejecting values which were previously acceptd, to prevent a Python crash.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36819>
_______________________________________


More information about the Python-bugs-list mailing list