Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast.Constant.n deprecated without warning #90953

Closed
jwilk mannequin opened this issue Feb 19, 2022 · 3 comments
Closed

ast.Constant.n deprecated without warning #90953

jwilk mannequin opened this issue Feb 19, 2022 · 3 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir

Comments

@jwilk
Copy link
Mannequin

jwilk mannequin commented Feb 19, 2022

BPO 46797
Nosy @jwilk, @serhiy-storchaka
PRs
  • gh-90953: Emit deprecation warnings for deprecated ast features #31432
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-19.08:29:16.968>
    labels = ['library', '3.11']
    title = 'ast.Constant.n deprecated without warning'
    updated_at = <Date 2022-02-19.12:24:07.912>
    user = 'https://github.com/jwilk'

    bugs.python.org fields:

    activity = <Date 2022-02-19.12:24:07.912>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-02-19.08:29:16.968>
    creator = 'jwilk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46797
    keywords = ['patch']
    message_count = 2.0
    messages = ['413541', '413546']
    nosy_count = 2.0
    nosy_names = ['jwilk', 'serhiy.storchaka']
    pr_nums = ['31432']
    priority = 'low'
    resolution = 'postponed'
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46797'
    versions = ['Python 3.11']

    Linked PRs

    @jwilk
    Copy link
    Mannequin Author

    jwilk mannequin commented Feb 19, 2022

    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

    @jwilk jwilk mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir labels Feb 19, 2022
    @serhiy-storchaka
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    AlexWaygood added a commit that referenced this issue May 6, 2023
    …Python 3.8 (#104199)
    
    `ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` now all emit deprecation warnings on import, access, instantation or `isinstance()` checks.
    
    Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
    jbower-fb pushed a commit to jbower-fb/cpython-jbowerfb that referenced this issue May 8, 2023
    …ed in Python 3.8 (python#104199)
    
    `ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` now all emit deprecation warnings on import, access, instantation or `isinstance()` checks.
    
    Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
    AlexWaygood added a commit to AlexWaygood/cpython that referenced this issue May 9, 2023
    carljm added a commit to carljm/cpython that referenced this issue May 10, 2023
    * main:
      pythonGH-102181: Improve specialization stats for SEND (pythonGH-102182)
      pythongh-103000: Optimise `dataclasses.asdict` for the common case (python#104364)
      pythongh-103538: Remove unused TK_AQUA code (pythonGH-103539)
      pythonGH-87695: Fix OSError from `pathlib.Path.glob()` (pythonGH-104292)
      pythongh-104263: Rely on Py_NAN and introduce Py_INFINITY (pythonGH-104202)
      pythongh-104010: Separate and improve docs for `typing.get_origin` and `typing.get_args` (python#104013)
      pythongh-101819: Adapt _io._BufferedIOBase_Type methods to Argument Clinic (python#104355)
      pythongh-103960: Dark mode: invert image brightness (python#103983)
      pythongh-104252: Immortalize Py_EMPTY_KEYS (pythongh-104253)
      pythongh-101819: Clean up _io windows console io after pythongh-104197 (python#104354)
      pythongh-101819: Harden _io init (python#104352)
      pythongh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (pythonGH-104226)
      pythongh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (python#103849)
      pythongh-74895: adjust tests to work on Solaris (python#104326)
      pythongh-101819: Refactor _io in preparation for module isolation (python#104334)
      pythongh-90953: Don't use deprecated AST nodes in clinic.py (python#104322)
      pythongh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request()
      pythongh-104328: Fix typo in ``typing.Generic`` multiple inheritance error message (python#104335)
    @hugovk
    Copy link
    Member

    hugovk commented Jan 11, 2024

    A deprecation warning is now raised:

    Python 3.12.1 (v3.12.1:2305ca5144, Dec  7 2023, 17:23:38) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
    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
    <stdin>:1: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
    42

    @hugovk hugovk closed this as completed Jan 11, 2024
    bnebgen-LANL pushed a commit to bnebgen-LANL/ase that referenced this issue May 30, 2024
    This is to comply with Python 3.12.
    - python/cpython#90953
    
    For the reason why `ast.Num` was deprecated, one can refer to:
    - python/cpython#77073
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants