[Python-Dev] Are undocumented exceptions considered bugs?

Devin Jeanpierre jeanpierreda at gmail.com
Sun Mar 24 02:09:50 CET 2013

On Sat, Mar 23, 2013 at 11:21 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> In this specific case, the error message is
> confusing-but-not-really-wrong, due to the "two-types-in-one" nature
> of Python 2.x strings - 8-bit strings are used as both text sequences
> (generally not containing NUL characters) and also as arbitrary binary
> data, including encoded text (quite likely to contain NUL bytes).

With your terminology, three types: char, non-NUL-text, encoded-text
(e.g. what happens with ord('ab'))

That's pretty silly, considering that these are all one Python type,
and TypeError is raised into Python code. Obviously it can't change,
because of historical reasons, but documenting it would be
straightforward and helpful. These are not errors you can just infer
will happen, you need to see it via documentation, reading the source,
or experimentation (and re experimentation, then you have to establish
whether or not this was an accident or deliberate).

-- Devin

More information about the Python-Dev mailing list