Nov. 23, 2020
2:06 a.m.
Brett Cannon <brett@python.org> added the comment: I think operator.index() should be brought to be inline with PyNumber_Index(): - If the argument is a subclass of int then return it. - Otherwise call type(obj).__index__(obj) - If not an int, raise TypeError - If not a direct int, raise a DeprecationWarning The language reference for __index__() suggests this is the direction to go (https://docs.python.org/3/reference/datamodel.html#object.__index__). ---------- nosy: +brett.cannon _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue17576> _______________________________________