original) (raw)
(On Sun, Mar 24, 2013 at 2:09 AM, Devin Jeanpierre <jeanpierreda@gmail.com> wrote:
On Sat, Mar 23, 2013 at 11:21 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:With your terminology, three types: char, non-NUL-text, encoded-text
> 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).
(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).
Thanks for your answers, guys, and sorry for replying so late (had a research paper submission deadline in the mean time...). Filing a bug report for this issue sounds like a good idea. I have just submitted�http://bugs.python.org/issue17624
Stefan