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 — Incorrect information about exception raised if source contains null bytes for ast.parse() and compile() · Issue #122461 · python/cpython

Incorrect information about exception raised if source contains null bytes for ast.parse() and compile() #122461

New issue
Copy link
New issue
Copy link
Open
Open
Incorrect information about exception raised if source contains null bytes for ast.parse() and compile()#122461
Copy link
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@devdanzin
devdanzin
opened on Jul 30, 2024
Issue body actions

Documentation

Docs for compile() and ast.parse() say they raise ValueError for source contains null bytes. However, since 3.12 (#97594), SyntaxError is raised instead:

>>> compile("\x00", "lambda.tt", "exec")
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    compile("\x00", "lambda.tt", "exec")
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: source code string cannot contain null bytes

cpython/Doc/library/functions.rst

Lines 337 to 338 in d1a1bca

This function raises :exc:`SyntaxError` if the compiled source is invalid,
and :exc:`ValueError` if the source contains null bytes.

And

cpython/Doc/library/ast.rst

Line 2158 in d1a1bca

If source contains a null character (``\0``), :exc:`ValueError` is raised.

Linked PRs

  • gh-122461: Document that compile() and ast.parse() raise SyntaxError for null bytes #122462

Activity

  1. devdanzin
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Jul 30, 2024
  2. Eclips4
    added
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Jul 30, 2024
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

    3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

    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.