[issue16577] Suspect test.test_codeccallbacks.test_mutatingdecodehandler
Walter Dörwald
report at bugs.python.org
Thu Nov 29 17:48:11 CET 2012
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 <report at bugs.python.org>
<http://bugs.python.org/issue16577>
_______________________________________
More information about the Python-bugs-list
mailing list