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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
devdanzin opened this issue Jul 30, 2024 · 0 comments
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes docs Documentation in the Doc dir

Comments

@devdanzin
Copy link
Contributor
devdanzin commented Jul 30, 2024

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

@devdanzin devdanzin added the docs Documentation in the Doc dir label Jul 30, 2024
@Eclips4 Eclips4 added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants
0