Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
The__index__() special method was introduced to make other integer-like types which are notint subclasses to be accepted as integer arguments.
It is supported by allPyArg_Parse format units for integers, exceptk (long sized bitfield) andK (long long sized bitfield). Argument Clinic has the same behavior forunsigned_long(bitwise=True) andunsigned_long_long(bitwise=True). It supports also non-bitwise unsigned integer converters, all of them do not support__index__().
Note that makingPyLong_AsUnsignedLong() andPyLong_AsUnsignedLongLong() to support__index__() is potentially unsafe. But the higher level code that uses them, can be changed.
Linked PRs
- gh-132987: Support __index__() for "k" and "K" formats in PyArg_Parse #132988
- gh-132987: Support __index__() for unsigned integers in Argument Clinic #133011
- gh-132987: Support __index__() in the socket module #133093
- gh-132987: Support __index__() in the select.kqueue_event constructor #133094
- gh-132987: Support __index__() in the posix module #133096
- gh-132987: Support __index__() in the stat module #133097
- gh-132987: Support __index__() in the ssl.SSLContext.options setter #133098
- gh-132987: Support __index__() in the lzma module #133099
- gh-132987: Support __index__() in hashlib.scrypt() #133100