[issue45086] f-string unmatched ']'

Terry J. Reedy report at bugs.python.org
Fri Sep 3 22:07:00 EDT 2021


Terry J. Reedy <tjreedy at udel.edu> added the comment:

The behavior remains the same in 3.11 ('main' branch).  New PEG parser parses this the same.

(Pablo, if there is a mistake below, please correct.)

Normally, the parser copies code chars between quotes, with or without '\' interpretation, into a string object.  When the 'f' prefix is given, the string gets divided into substrings and replacement fields.  The code part of each replacement field is separately parsed.  There are two options: 1. parse the field code while looking for an endcode marker; 2. look ahead for an endcode marker and then parse the code.

The current behavior is consistent with opotion 1 and the python policy of reporting the first error found and exiting, rather than trying to resynchronize to try to find more errors.

----------
nosy: +pablogsal, terry.reedy
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45086>
_______________________________________


More information about the Python-bugs-list mailing list