[issue45034] Improve struct.pack out of range error messages
Mark Dickinson
report at bugs.python.org
Tue Sep 7 08:25:15 EDT 2021
Mark Dickinson <dickinsm at gmail.com> added the comment:
The out-of-range error messages for unsigned short and short have been fixed, thanks to Nikita Sobolev. They resulted from a rather odd use of the Py_STRINGIFY macro, which meant that not only were the messages obscure, but they differed from system to system: e.g., on my machine I get: "struct.error: ushort format requires 0 <= number <= (32767 *2 +1)", and "struct.error: short format requires (-32767 -1) <= number <= 32767", complete with the weird spacing.
There's still room for normalising the other messages and/or converting the limits to hex if anyone wants to provide a PR.
I'm unsure about using hex universally: while `0xffffffffffffffff` (or even better, `0xffff_ffff_ffff_ffff`) is definitely more useful than `18446744073709551615`, I think I'd still find `-128` more immediately readable than `-0x80`.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45034>
_______________________________________
More information about the Python-bugs-list
mailing list