Is this the right way to write a codec error handler?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Jan 20 20:47:26 EST 2018


On Sat, 20 Jan 2018 12:57:45 +0200, Serhiy Storchaka wrote:

> Just `end` instead of `end+1`.

Oops!

> And it is safer to use `bytes.decode(obj[start:end], 'latin1')` or
> `str(obj[start:end], 'latin1')` instead of
> `obj[start:end].decode('latin1')`. Just for the case if obj has
> overridden decode() method.
> 
> Otherwise LGTM.

Thanks.



-- 
Steve




More information about the Python-list mailing list