-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Description
Originally reported by: Evan (Bitbucket: evan_, GitHub: Unknown)
The documentation states that int2byte is "equivalent to [...] bytes((i,)) in Python 3", which is not true for invalid values.
#!python
>>> bytes(('a',))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object cannot be interpreted as an integer
>>> int2byte('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
struct.error: required argument is not an integer
>>>
>>> bytes((256,))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: bytes must be in range(0, 256)
>>> int2byte(256)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
struct.error: ubyte format requires 0 <= number <= 255
From #122 I can see that performance is a concern. Personally I'd like to see this implemented as described in the documentation, but alternatively the documentation could be updated to mention the inconsistency.
- Bitbucket: https://bitbucket.org/gutworth/six/issue/163