-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression before =
in an f-string is interpreted like a normal string with escape sequences
#124363
Comments
Hummmm, I am not sure this is a bug as this wasn't specified at the moment we started to allow escape sequences so we should first decide if this makes sense. CC: @lysnikolaou @ericvsmith . This is possible but unfortunately a bit annoying to implement because the current shape of the AST doesn't properly pass down what is debug and what is not. I think I can try to move stuff around to eliminate this problem and make it work. I will create a draft for evaluation |
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…ythonGH-128399) (cherry picked from commit 60a3a0d) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…rings (pythonGH-128399) (cherry picked from commit 60a3a0d) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Bug report
Bug description:
When an f-string contains an
=
specifier, the characters before the equals sign are interpreted as if they were within a normal string. In particular, a backslash is always interpreted as starting an escape sequence, even when it doesn’t, which causes unexpected output.Those results are misleading because the expressions printed before the equals signs are either syntax errors or do not match the values printed after the equals signs. I expected these results:
Even when the result is not so misleading, it would still be more helpful for debugging if the output kept the expression unmodified, instead of interpreting the escape sequences. For example, this:
would be better as this:
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: