Skip to content

Commit

Permalink
Reword Whats New note (based on suggestion by Alex Waygood)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Feb 27, 2024
1 parent 54cf55f commit 4bb0656
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,21 @@ array
ast
---

* The constructors of node types in the :mod:`ast` module are stricter
in the arguments they accept. If an optional field is not passed to the
constructor, it is set to ``None``, and if a list field is not passed,
it is set to the empty list. (Previously, the attribute would be missing.)
If any other field is not passed to the constructor, a :exc:`DeprecationWarning`
is raised. This will raise an exception in Python 3.15. Similarly, passing
a keyword argument that does not map to a field on the AST node now raises
a :exc:`DeprecationWarning` and will raise an exception in Python 3.15.
* The constructors of node types in the :mod:`ast` module are now stricter
in the arguments they accept, and have more intuitive behaviour when
arguments are omitted.

If an optional field on an AST node is not included as an argument when
constructing an instance, the field will now be set to ``None``. Similarly,
if a list field is omitted, that field will now be set to an empty list.
(Previously, in both cases, the attribute would be missing on the newly
constructed AST node instance.)

If other arguments are omitted, a :exc:`DeprecationWarning` is emitted.
This will cause an exception in Python 3.15. Similarly, passing a keyword
argument that does not map to a field on the AST node is now deprecated,
and will raise an exception in Python 3.15.

* :func:`ast.parse` now accepts an optional argument ``optimize``
which is passed on to the :func:`compile` built-in. This makes it
possible to obtain an optimized ``AST``.
Expand Down

0 comments on commit 4bb0656

Please sign in to comment.