You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> (-2).to_bytes(2,'big',True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: value must fit in 2 byte(s)
Works properly in CPython, except the third argument is a keyword-only argument in CPython, so you have to use .to_bytes(2, 'big', signed=True). That should be fixed too.
The workaround is to use struct.pack(), which does not throw an error.