This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 serhiy.storchaka
收信人 Arfrever, alex, barry, brett.cannon, docs@python, eric.snow, ethan.furman, mark.dickinson, mjacob, ncoghlan, python-dev, rhettinger, serhiy.storchaka, vstinner
日期 2021-08-31.10:27:05
SpamBayes Score -1.0
Marked as misclassified
Message-id <1630405625.47.0.942758627213.issue17576@roundup.psfhosted.org>
In-reply-to
内容
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.
历史
日期 用户 动作 参数
2021-08-31 10:27:05serhiy.storchaka修改recipients: + serhiy.storchaka, barry, brett.cannon, rhettinger, mark.dickinson, ncoghlan, vstinner, Arfrever, alex, docs@python, ethan.furman, python-dev, eric.snow, mjacob
2021-08-31 10:27:05serhiy.storchaka修改messageid: <1630405625.47.0.942758627213.issue17576@roundup.psfhosted.org>
2021-08-31 10:27:05serhiy.storchaka链接issue17576 messages
2021-08-31 10:27:05serhiy.storchaka创建