Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ and classes for traversing abstract syntax trees:
is no guarantee that the parse (or success of the parse) is the same as
when run on the Python version corresponding to ``feature_version``.

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

.. warning::
Note that successfully parsing source code into an AST object doesn't
Expand All @@ -2176,6 +2176,10 @@ and classes for traversing abstract syntax trees:
.. versionchanged:: 3.8
Added ``type_comments``, ``mode='func_type'`` and ``feature_version``.

.. versionchanged:: 3.12
Previously, :exc:`ValueError` was raised when null bytes were encountered
in *source*.

.. versionchanged:: 3.13
The minimum supported version for ``feature_version`` is now ``(3, 7)``.
The ``optimize`` argument was added.
Expand Down
7 changes: 5 additions & 2 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ are always available. They are listed here in alphabetical order.
``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
or ``2`` (docstrings are removed too).

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

If you want to parse Python code into its AST representation, see
:func:`ast.parse`.
Expand Down Expand Up @@ -371,6 +371,9 @@ are always available. They are listed here in alphabetical order.
``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable
support for top-level ``await``, ``async for``, and ``async with``.

.. versionchanged:: 3.12
Previously, :exc:`ValueError` was raised when null bytes were encountered
in *source*.

.. class:: complex(number=0, /)
complex(string, /)
Expand Down