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. |