Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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: 4 additions & 2 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2155,8 +2155,6 @@ 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.

.. warning::
Note that successfully parsing source code into an AST object doesn't
guarantee that the source code provided is valid Python code that can
Expand All @@ -2176,6 +2174,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 instead of :exc:`SyntaxError`
when null characters (``\0``) 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
6 changes: 4 additions & 2 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ 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.

If you want to parse Python code into its AST representation, see
:func:`ast.parse`.
Expand Down Expand Up @@ -371,6 +370,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 instead of :exc:`SyntaxError` when
null characters (``\0``) were encountered in *source*.

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