Message176661
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. |
|
Date |
User |
Action |
Args |
2012-11-29 16:48:11 | doerwalter | set | recipients:
+ doerwalter, amaury.forgeotdarc, vstinner, ezio.melotti |
2012-11-29 16:48:11 | doerwalter | set | messageid: <1354207691.28.0.489514113498.issue16577@psf.upfronthosting.co.za> |
2012-11-29 16:48:11 | doerwalter | link | issue16577 messages |
2012-11-29 16:48:10 | doerwalter | create | |
|