[issue21177] ValueError: byte must be in range(0, 256)

Konstantin Zemlyak report at bugs.python.org
Fri Apr 11 07:27:15 CEST 2014


Konstantin Zemlyak added the comment:

To clarify few things:

- Yes, I know that 256 doesn't fit into byte. I was checking how bytes/bytearray are handling overflow.
- I know that range() is a half-open interval.

Yet this error message still gave me a "wtf" moment because I didn't realize it was talking about python's range() builtin and not about mathematical term. So even though this message is technically 100% correct it still doesn't feel right.

May I propose a message "byte must be in range [0-255]" instead? This won't be confused with either python's range() nor [] list notation.

----------

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


More information about the Python-bugs-list mailing list