← 输入框|bugs.python.org|刷新

➜

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.

classification
标题: ast.Constant.n deprecated without warning
类型: Stage: patch review
Components: Library (Lib) Versions: Python 3.11
process
状态: open Resolution: postponed
Dependencies: 后续:
分配给: 抄送列表: jwilk, serhiy.storchaka
优先级: low 关键字: patch

jwilk 于 2022-02-19 08:29 创建。最近一次由 admin 于 2022-04-11 14:59 修改。

Pull Requests
URL Status Linked Edit
PR 31432 open serhiy.storchaka, 2022-02-19 12:22
Messages (2)
msg413541 - (view) Author: Jakub Wilk (jwilk) 日期: 2022-02-19 08:29
ast.Constant.n is documented to be deprecated, but you don't get any warning when you use it:

$ python3.11 -Wd
Python 3.11.0a5 (main, Feb 12 2022, 17:11:59) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> help(ast.Constant.n)
Help on property:

    Deprecated. Use value instead.

>>> ast.Constant(value=42).n
42
msg413546 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) 日期: 2022-02-19 12:24
It is because we did not have a plan for removing deprecates features. Deprecation in documentation only helps third-party code. Instead of adding a complex code which switches between using old and new names depending on Python version, the third-party code can continue to use old names without worring about deprecation warnings, and switch completely to using new features only when support of old Python versions be dropped. 3.7 and 3.8 are not so old and may be still supported in third-party code.

I have created a PR which adds deprecation warnings, but I am not sure that it is worth to include it in 3.11.
历史
日期 用户 动作 参数
2022-04-11 14:59:56admin修改github: 90953
2022-02-19 12:24:07serhiy.storchaka修改优先级: normal -> low
resolution: postponed
消息: + msg413546
2022-02-19 12:22:18serhiy.storchaka修改keywords: + patch
stage: patch review
pull_requests: + pull_request29567
2022-02-19 08:29:16jwilk创建