8000 Incorrect information about exception raised if source contains null bytes for ast.parse() and compile() · Issue #122461 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Incorrect information about exception raised if source contains null bytes for ast.parse() and compile() #122461
Open
@devdanzin

Description

@devdanzin

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

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

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0