Message219609
I reconsidered this in the light of #21559. getargs_b requires an integer of type int in range(256). A non-int properly raises TypeError.
>>> from _testcapi import getargs_b as gb
>>> gb(1.0)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
gb(1.0)
TypeError: integer argument expected, got float
>>> import fractions
>>> gb(fractions.Fraction(1, 1))
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
gb(fractions.Fraction(1, 1))
TypeError: an integer is required (got type Fraction)
An out-of-range int should, it seems to me, just raise ValueError("int %d not in range(256)" % n). Verification of the range:
>>> gb(255)
255
>>> gb(256)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
gb(256)
OverflowError: unsigned byte integer is greater than maximum
>>> gb(0)
0
>>> gb(-1)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
gb(-1)
OverflowError: unsigned byte integer is less than minimum
The last message is wrong or contradictory. An unsigned (non-negative) int cannot be less than 0. |
|
| Date |
User |
Action |
Args |
| 2014-06-02 17:27:47 | terry.reedy | set | recipients:
+ terry.reedy, mark.dickinson, ezio.melotti, serhiy.storchaka |
| 2014-06-02 17:27:47 | terry.reedy | set | messageid: <[email protected]> |
| 2014-06-02 17:27:47 | terry.reedy | link | issue15988 messages |
| 2014-06-02 17:27:47 | terry.reedy | create | |
|