This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients steven.daprano, terry.reedy
Date 2021-09-04.00:27:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630715230.48.0.150516535695.issue45034@roundup.psfhosted.org>
In-reply-to
Content
I agree, including use of hex, if possible, for unsigned (non-negative) values.

Grepping 'format requires' returns
F:\dev\3x\Modules\_struct.c: 365:             "'%c' format requires 0 <= number <= %zu",
F:\dev\3x\Modules\_struct.c: 371:             "'%c' format requires %zd <= number <= %zd",
F:\dev\3x\Modules\_struct.c: 550:                         "byte format requires -128 <= number <= 127");
F:\dev\3x\Modules\_struct.c: 565:                         "ubyte format requires 0 <= number <= 255");
F:\dev\3x\Modules\_struct.c: 577:                         "char format requires a bytes object of length 1");
F:\dev\3x\Modules\_struct.c: 593:                         "short format requires " Py_STRINGIFY(SHRT_MIN)
F:\dev\3x\Modules\_struct.c: 611:                         "ushort format requires 0 <= number <= "
                                                           Py_STRINGIFY(USHRT_MAX));

I believe l365 is the source for the 2nd example.  AFAIK, 'zu' is not valid for either C printf or Python % formating.
Lines 611 and 612 are the source for the 1st example.  From comments before line 365, there can be issues with lefts shifts, but '0xffff', '0xffff_ffff', and '0xffff_ffff_ffff_ffff' could be hard-coded strings that would cover all 'normal' systems.

Grepping "argument out of range" returns
F:\dev\3x\Modules\_struct.c: 168:                             "argument out of range");
F:\dev\3x\Modules\_struct.c: 192:                             "argument out of range");
F:\dev\3x\Modules\_struct.c: 215:                             "argument out of range");
F:\dev\3x\Modules\_struct.c: 238:                             "argument out of range");
F:\dev\3x\Modules\_struct.c: 261:                             "argument out of range");
F:\dev\3x\Modules\_struct.c: 284:                             "argument out of range");

It is nnclear to me without more reading why some codes lead to this less helpful message.
History
Date User Action Args
2021-09-04 00:27:10terry.reedysetrecipients: + terry.reedy, steven.daprano
2021-09-04 00:27:10terry.reedysetmessageid: <1630715230.48.0.150516535695.issue45034@roundup.psfhosted.org>
2021-09-04 00:27:10terry.reedylinkissue45034 messages
2021-09-04 00:27:10terry.reedycreate