Terry J. Reedy added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com