Skip to content

gh-133197: Improve error message for ft"" and bt"" cases#133202

Merged
sobolevn merged 4 commits into
python:mainfrom
sobolevn:issue-133196
Apr 30, 2025
Merged

gh-133197: Improve error message for ft"" and bt"" cases#133202
sobolevn merged 4 commits into
python:mainfrom
sobolevn:issue-133196

Conversation

@sobolevn

@sobolevn sobolevn commented Apr 30, 2025

Copy link
Copy Markdown
Member

@sobolevn

Copy link
Copy Markdown
Member Author

Hm, looks like other string prefixes can also conflict with no clear message. Examples:

>>> tb''
  File "<python-input-3>", line 1
    tb''
      ^^
SyntaxError: invalid syntax

>>> fb''
  File "<python-input-0>", line 1
    fb''
      ^^
SyntaxError: invalid syntax

>>> ru''
  File "<python-input-1>", line 1
    ru''
      ^^
SyntaxError: invalid syntax

>>> bu''
  File "<python-input-2>", line 1
    bu''
      ^^
SyntaxError: invalid syntax

Let's handle all t cases here maybe and u-string prefixes in the next PR? It would much easier for me.

@sobolevn sobolevn changed the title gh-133196: Improve error message for ft"" case gh-133196: Improve error message for ft"" and bt"" cases Apr 30, 2025

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

Left a couple of comments inline. Also, it appears that the issue number is wrong. Could you change it please?

Comment thread Lib/test/test_syntax.py Outdated
Comment thread Parser/lexer/lexer.c Outdated
@sobolevn

Copy link
Copy Markdown
Member Author

Now we have prefixes highlighted:
Снимок экрана 2025-04-30 в 15 19 42
Снимок экрана 2025-04-30 в 15 19 12

@sobolevn sobolevn changed the title gh-133196: Improve error message for ft"" and bt"" cases gh-133197: Improve error message for ft"" and bt"" cases Apr 30, 2025

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

LGTM! This is a nice improvement! Let's follow up with the rest of the prefixes.

@sobolevn sobolevn merged commit b451516 into python:main Apr 30, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants