Walter Dörwald added the comment:
True, the second test uses the wrong error handler.
And yes, you're correct, bytes are now immutable. And even if I try to decode a
bytearray, what the callback gets to see is still an immutable bytes object::
import codecs
def mutating(exc):
if isinstance(exc, UnicodeDecodeError):
exc.object[:] = b""
return ("\u4242", 0)
else:
raise TypeError("don't know how to handle %r" % exc)
codecs.register_error('mutating', mutating)
input = bytearray(b'bbb\xff')
input.decode('ascii', 'mutating')
This still raises:
TypeError: 'bytes' object does not support item assignment
So the change should indeed be reverted.
----------
nosy: +doerwalter
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16577>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com