Skip to content

bpo-38964: Print correct filename on a SyntaxError in an fstring#20399

Merged
pablogsal merged 5 commits into
python:masterfrom
lysnikolaou:filename-fstring-syntaxerrors
May 26, 2020
Merged

bpo-38964: Print correct filename on a SyntaxError in an fstring#20399
pablogsal merged 5 commits into
python:masterfrom
lysnikolaou:filename-fstring-syntaxerrors

Conversation

@lysnikolaou

@lysnikolaou lysnikolaou commented May 25, 2020

Copy link
Copy Markdown
Member

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.

https://bugs.python.org/issue38964

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.
@lysnikolaou

Copy link
Copy Markdown
Member Author

Can this be backported to 3.9?

@pablogsal

Copy link
Copy Markdown
Member

Can this be backported to 3.9?

The test would need a skip for the old parser if we backport this to 3.9

@ericvsmith ericvsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Lib/test/test_fstring.py Outdated
Comment thread Lib/test/test_fstring.py Outdated
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @lysnikolaou and @pablogsal, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker f7b1e461567e5e3fa3ba46f589d9edc1b45b2dd0 3.9

@pablogsal

Copy link
Copy Markdown
Member

@lysnikolaou Can you do the backport using cherry_picker?

@lysnikolaou

Copy link
Copy Markdown
Member Author

On it.

lysnikolaou added a commit to lysnikolaou/cpython that referenced this pull request May 26, 2020
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>
@bedevere-bot

Copy link
Copy Markdown

GH-20404 is a backport of this pull request to the 3.9 branch.

@lysnikolaou
lysnikolaou deleted the filename-fstring-syntaxerrors branch May 26, 2020 00:42
pablogsal pushed a commit that referenced this pull request May 26, 2020
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants