gh-93283: Improve error message for f-string with invalid conversion character#93349
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
What error should be for f'{3!g'? "invalid conversion character" or "expecting '}'"?
What error should be for f'{3!:'? "missed conversion character" or "expecting '}'"?
|
Personally, I'd expect A |
|
Btw we are just working on this in the "porting f-strings to the grammar" project in case you have time to help @serhiy-storchaka |
|
It is easy for |
| "expected 's', 'r', or 'a'" % conv, | ||
| ["f'{3!" + conv + "}'"]) | ||
|
|
||
| self.assertAllRaise(SyntaxError, |
There was a problem hiding this comment.
Somewhere we should probably add whitespace both before and after the conversion character: "s ", " s", " s ". It looks like that got dropped.
The idea is good at first glance, I thought about it, but it looks too complicated. The main problem is that the closing quote must match the opening one. It can be solved, but it needs significant effort. There are easier and more important problems. |
#93283.