[docs] [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

Mark Dickinson report at bugs.python.org
Sun Jun 2 06:27:17 EDT 2019


Mark Dickinson <dickinsm at gmail.com> added the comment:

I'm working on a PR that finally changes the DeprecationWarnings that Serhiy introduced to TypeErrors; I think that should be acceptable, four Python versions and some years later. With that PR:

- int will always return something of exact type `int` (or raise)
- operator.index will always return something of exact type `int` (or raise)
- PyNumber_Index will always use `__index__` for int subclasses, so this should fix the issue that Barry originally reported (mismatch between `obj.__index__()` and `operator.index(obj)`).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17576>
_______________________________________


More information about the docs mailing list