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 — ast.parse() without optimize=True doesn't error on invalid AST type · Issue #130139 · python/cpython

ast.parse() without optimize=True doesn't error on invalid AST type #130139

New issue
Copy link
New issue
Copy link
Closed
Closed
ast.parse() without optimize=True doesn't error on invalid AST type#130139
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@iritkatriel
iritkatriel
opened on Feb 15, 2025
Issue body actions
>>> ast.parse(ast.Constant(42))
Constant(value=42, kind=None)


>>> ast.parse(ast.Constant(42), optimize=True)
Traceback (most recent call last):
  File "<python-input-4>", line 1, in <module>
    ast.parse(ast.Constant(42), optimize=True)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/ast.py", line 53, in parse
    return compile(source, filename, mode, flags,
                   _feature_version=feature_version, optimize=optimize)
TypeError: expected Module node, got Constant

(This came up while implementing PEP 765 #130080).

Linked PRs

  • gh-130139: always check ast node type in ast.parse() with ast input #130140

Activity

  1. iritkatriel
    added 2 commits that reference this issue on Feb 15, 2025

    pythongh-130139: always check ast node type in ast.parse() with ast i…

    1c48f0b

    pythongh-130139: always check ast node type in ast.parse() with ast i…

    117152f
  2. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Feb 15, 2025
  3. iritkatriel
    added a commit that references this issue on Feb 16, 2025

    gh-130139: always check ast node type in ast.parse() with ast input (#…

    c9b1bf3
  4. tomasr8 commented on Feb 17, 2025

    @tomasr8
    tomasr8
    on Feb 17, 2025
    Member
    More actions

    PR merged, can we close the issue or is there something left to do?

  5. iritkatriel
    closed this as completedon Feb 17, 2025
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-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 01402520 — 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.