Terry J. Reedy <tjre...@udel.edu> added the comment:

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.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45034>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to