-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir
Description
c.f. PyLong_AsUInt32/64():
If obj is not an instance of PyLongObject, first call its
__index__()
method (if present) to convert it to a PyLongObject.
In fact, there is no difference for signed/unsigned:
cpython/Lib/test/test_capi/test_long.py
Lines 691 to 695 in 3ec3d05
def test_long_asint32(self): | |
# Test PyLong_AsInt32() and PyLong_FromInt32() | |
to_int32 = _testlimitedcapi.pylong_asint32 | |
from _testcapi import INT32_MIN, INT32_MAX | |
self.check_long_asint(to_int32, INT32_MIN, INT32_MAX) |
cpython/Lib/test/test_capi/test_long.py
Lines 703 to 708 in 3ec3d05
def test_long_asuint32(self): | |
# Test PyLong_AsUInt32() and PyLong_FromUInt32() | |
as_uint32 = _testlimitedcapi.pylong_asuint32 | |
from _testcapi import UINT32_MAX | |
self.check_long_asint(as_uint32, 0, UINT32_MAX, | |
negative_value_error=ValueError) |
where check_long_asint() tests
__index__()
dunder per default:cpython/Lib/test/test_capi/test_long.py
Lines 166 to 169 in 3ec3d05
def check_long_asint(self, func, min_val, max_val, *, | |
use_index=True, | |
mask=False, | |
negative_value_error=OverflowError): |
So, same note should be added for PyLong_AsInt32/64()
Linked PRs
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo