[issue17828] More informative error handling when encoding and decoding
Nick Coghlan
report at bugs.python.org
Tue Nov 5 15:16:55 CET 2013
Nick Coghlan added the comment:
Checking the other binary<->binary and str<->str codecs with input type and value restrictions:
- they all throw TypeError and get wrapped appropriately when asked to encode str input (rot_13 throws the output type error)
- rot_13 throws an appropriately wrapped AttributeError when asked to decode bytes or bytearray object
For bad value input, "uu_codec" is the only one that throws a normal ValueError, I couldn't figure out a way to get "quopri_codec" to complain about the input value and the others throw a module specific error:
binascii (base64_codec, hex_codec) throws binascii.Error (a custom ValueError subclass)
zlib (zlib_codec) throws zlib.error (inherits directly from Exception)
As with the OSError that escapes from bz2_codec, I think the simplest and most conservative option is to not worry about those at this point.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17828>
_______________________________________
More information about the Python-bugs-list
mailing list