PEP 701: Specify a lower bound for the nesting level (#3048)

This commit is contained in:
Pablo Galindo Salgado 2023-03-10 16:38:58 +00:00 committed by GitHub
parent a44796ee65
commit d318dc8329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 8 deletions

View File

@ -9,6 +9,7 @@ Type: Standards Track
Content-Type: text/x-rst Content-Type: text/x-rst
Created: 15-Nov-2022 Created: 15-Nov-2022
Python-Version: 3.12 Python-Version: 3.12
Post-History: `19-Dec-2022 <https://discuss.python.org/t/pep-701-syntactic-formalization-of-f-strings/22046>`__,
Abstract Abstract
@ -225,9 +226,12 @@ for details on the syntax):
The new tokens (``FSTRING_START``, ``FSTRING_MIDDLE``, ``FSTRING_END``) are defined The new tokens (``FSTRING_START``, ``FSTRING_MIDDLE``, ``FSTRING_END``) are defined
:ref:`later in this document <701-new-tokens>`. :ref:`later in this document <701-new-tokens>`.
This PEP leaves up to the implementation the level of f-string nesting allowed. This PEP leaves up to the implementation the level of f-string nesting allowed but
This means that limiting nesting is **not part of the language specification** **specifies a lower bound of 5 levels of nesting**. This is to ensure that users can
but also the language specification **doesn't mandate arbitrary nesting**. have a reasonable expectation of being able to nest f-strings with "reasonable" depth.
This PEP implies that limiting nesting is **not part of the language
specification** but also the language specification **doesn't mandate arbitrary
nesting**.
The new grammar will preserve the Abstract Syntax Tree (AST) of the current The new grammar will preserve the Abstract Syntax Tree (AST) of the current
implementation. This means that no semantic changes will be introduced by this implementation. This means that no semantic changes will be introduced by this