bpo-38964: Print correct filename on a SyntaxError in an fstring#20399
Conversation
When a `SyntaxError` in the expression part of an fstring is found, the filename attribute of the `SyntaxError` is always `<fstring>`. With this PR it gets changed to always have the name of the file the fstring resides in.
|
Can this be backported to 3.9? |
The test would need a skip for the old parser if we backport this to |
ericvsmith
left a comment
There was a problem hiding this comment.
This looks good to me. Thanks for fixing this, @lysnikolaou!
I have one tiny nit mentioned below, which you can ignore if you don't think it's important.
I think this should be backported to 3.9. It's clearly a bug.
|
Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
Sorry, @lysnikolaou and @pablogsal, I could not cleanly backport this to |
|
@lysnikolaou Can you do the backport using |
|
On it. |
pythonGH-20399) When a `SyntaxError` in the expression part of a fstring is found, the filename attribute of the `SyntaxError` is always `<fstring>`. With this commit, it gets changed to always have the name of the file the fstring resides in. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>. (cherry picked from commit f7b1e46) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
|
GH-20404 is a backport of this pull request to the 3.9 branch. |
GH-20399) (GH-20404) When a `SyntaxError` in the expression part of a fstring is found, the filename attribute of the `SyntaxError` is always `<fstring>`. With this commit, it gets changed to always have the name of the file the fstring resides in. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>. (cherry picked from commit f7b1e46)
When a
SyntaxErrorin the expression part of an fstring is found,the filename attribute of the
SyntaxErroris always<fstring>.With this PR it gets changed to always have the name of the file
the fstring resides in.
https://bugs.python.org/issue38964