[issue12170] index() and count() methods of bytes and bytearray should accept byte ints

Ezio Melotti report at bugs.python.org
Sun Jul 24 04:05:05 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

> When an integer out of range(0, 256) is passed as the first argument,
> should we raise a ValueError or a TypeError?

ValueError = Inappropriate argument value (of correct type).
TypeError = Inappropriate argument type.

> Currently, a ValueError raised, but this may be bad for index and 
> rindex, as they raise a ValueError when the substring or byte is not found.

Then the users should check if the value is in range(256) before passing it to (r)index.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12170>
_______________________________________


More information about the Python-bugs-list mailing list