Skip to content

Support __index__() for unsigned integer converters in PyArg_Parse and Argument Clinic #132987

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

The __index__() special method was introduced to make other integer-like types which are not int subclasses to be accepted as integer arguments.

It is supported by all PyArg_Parse format units for integers, except k (long sized bitfield) and K (long long sized bitfield). Argument Clinic has the same behavior for unsigned_long(bitwise=True) and unsigned_long_long(bitwise=True). It supports also non-bitwise unsigned integer converters, all of them do not support __index__().

Note that making PyLong_AsUnsignedLong() and PyLong_AsUnsignedLongLong() to support __index__() is potentially unsafe. But the higher level code that uses them, can be changed.

Linked PRs

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions