Skip to content

Deprecate creation of abstract AST nodes #116021

Description

@JelleZijlstra

Feature or enhancement

Proposal:

Currently all of these are allowed:

>>> import ast
>>> ast.expr()
<ast.expr object at 0x10526cce0>
>>> ast.stmt()
<ast.stmt object at 0x1054508d0>
>>> ast.AST()
<ast.AST object at 0x105229610>

But these are meant to be abstract classes; constructing them is not meaningful. I propose to raise a DeprecationWarning when they are constructed and raise an error a few versions down.

(Originally suggested by Cornelius Krupp on discuss.python.)

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/proposed-change-to-ast-node-constructors/46531/4

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions