Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

PyNumber_Index() now always returns an instance of int.

- If the argument is a direct int then return it.
- If it is a subclass of int then return a direct int copy.
- Otherwise call type(obj).__index__(obj)
- If a direct int, return it
- If a subclass of int, raise a DeprecationWarning and return a direct int copy
- If not an int, raise TypeError

If we go in this direction we should add a DeprecationWarning for __str__() 
returning not direct str. I am not sure that it is right. It adds a burden on 
authors of special methods to always convert the result to the corresponding 
direct type, while this conversion can silently (and more efficiently) be 
performed in the interpreter core.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue17576>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to