Issue 13830: codecs error handler is called with a UnicodeDecodeError with the same args (original) (raw)
The script below shows that the error handler is always called with the same error object. The 'start', 'end', and 'reason' properties are correctly updated, but the 'args' is always the same and holds the values used for the first call.
It's a bit weird that error.args[2] is not equal to error.start, for example. All versions are affected: 2.7, 3.2, 3.3. And by the way, I could not find where these are attributes documented.
def custom_handler(error): print(error.args, (error.start, error.end, error.reason)) return b'?'.decode(), error.end
import codecs codecs.register_error('custom', custom_handler) b'\x80\xd0'.decode('utf-8', 'custom')