Eric V. Smith <e...@trueblade.com> added the comment:

I don't think it really makes a difference, but here's some background:

For f-strings, the parser itself does not break apart the f-string into 
(<text>, <expression>) parts. There's a custom parser (at 
https://github.com/python/cpython/blob/0b58e863df9970b290a4de90c67f9ac30c443817/Parser/string_parser.c#L837)
 which does that. Then the normal parser is used to parse the expression 
portion.

I think the error shown here is not in the expression parser, but in the 
fstring parser in fstring_find_expr(), at 
https://github.com/python/cpython/blob/0b58e863df9970b290a4de90c67f9ac30c443817/Parser/string_parser.c#L665

As Terry says, it's not incorrect to print the error show in this bug report.

To further diverge:

There's been talk about using the normal parser to pull apart the entire 
f-string, instead of using the two-pass version I mention above. But we've 
never gotten past just talking about it. There are pros and cons for doing it 
with the normal parser, but that's a discussion for a different forum.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45086>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to