[Python-Dev] Changing string constants to byte arrays ([Python-checkins] r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py)
Walter Dörwald
walter at livinglogic.de
Fri May 4 16:29:15 CEST 2007
M.-A. Lemburg wrote:
> Hi Walter,
>
> if the bytes type does turn out to be a mutable type as suggested
> in PEP 358,
it is.
> then please make sure that no code (C code in
> particular), relies on the constantness of these byte objects.
>
> This is especially important when it comes to codecs, since
> the error callback logic would allow the callback to manipulate
> the byte object contents and length without the codec taking
> note of this change.
Encoding is not a problem because the error callback never sees or
returns a byte object.
However decoding is a problem. After the callback returns the codec has
to recalculate it's variables.
> I expect there to be other places in the interpreter which would
> break as well.
>
> Otherwise, you end up opening the door for segfaults and
> easy DOS attacks on Python3.
True, registering an even callback could crash the interpreter.
Seems we have to update all decoding functions.
Servus,
Walter
More information about the Python-Dev
mailing list