消息 [400707]
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:05 | serhiy.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:05 | serhiy.storchaka | 修改 | messageid: <1630405625.47.0.942758627213.issue17576@roundup.psfhosted.org> |
| 2021-08-31 10:27:05 | serhiy.storchaka | 链接 | issue17576 messages |
| 2021-08-31 10:27:05 | serhiy.storchaka | 创建 | |
|