GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate creation of abstract AST nodes · Issue #116021 · python/cpython

Deprecate creation of abstract AST nodes #116021

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate creation of abstract AST nodes#116021
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancementA feature request or enhancement

Description

@JelleZijlstra
JelleZijlstra
opened on Feb 28, 2024
Issue body actions

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

  • gh-116021: Deprecate support for instantiating abstract AST nodes #137865
Reacted by Kirill Podoprigora and Brian Schubert

Activity

  1. JelleZijlstra
    added
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-parser
    on Feb 28, 2024
  2. bzoracler commented on Feb 28, 2024

    @bzoracler
    bzoracler
    on Feb 28, 2024
    Contributor
    More actions

    Since there are no current and planned restrictions on subclassing these abstract nodes, I have a gut feeling that deprecating this behaviour will affect code which subclass these abstract nodes and which implicitly or explicitly call the superclass constructor.

    Projects which rely on AST enrichment pipelines (linters, code generators, Python-like language extensions, etc.) may rely on the current behaviour.

  3. brianschubert
    added a commit that references this issue on Sep 14, 2025

    Merge branch 'main' into pythongh-116021-ast-depr-abstract

    2f390c8
  4. brianschubert
    added a commit that references this issue on Oct 13, 2025

    Merge branch 'main' into pythongh-116021-ast-depr-abstract

    97dbdab
  5. brianschubert
    added a commit that references this issue on Nov 22, 2025

    Merge branch 'main' into pythongh-116021-ast-depr-abstract

    f8c0aef
  6. brianschubert
    added a commit that references this issue on Apr 28, 2026

    Merge branch 'main' into pythongh-116021-ast-depr-abstract

    0eb074e
  7. JelleZijlstra
    added a commit that references this issue on May 2, 2026

    gh-116021: Deprecate support for instantiating abstract AST nodes (#1…

    bdedc4a
  8. JelleZijlstra
    closed this as completedon May 2, 2026
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/ directoryStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.