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 ezio.melotti, mark.dickinson, serhiy.storchaka, terry.reedy
Date 2014-06-02.17:27:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1401730067.47.0.52862946311.issue15988@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-06-02 17:27:47terry.reedysetrecipients: + terry.reedy, mark.dickinson, ezio.melotti, serhiy.storchaka
2014-06-02 17:27:47terry.reedysetmessageid: <1401730067.47.0.52862946311.issue15988@psf.upfronthosting.co.za>
2014-06-02 17:27:47terry.reedylinkissue15988 messages
2014-06-02 17:27:47terry.reedycreate