Skip to content

gh-151128: Improve SyntaxError message for cross language keywords#151129

Open
zang-langyan wants to merge 4 commits into
python:mainfrom
zang-langyan:151128
Open

gh-151128: Improve SyntaxError message for cross language keywords#151129
zang-langyan wants to merge 4 commits into
python:mainfrom
zang-langyan:151128

Conversation

@zang-langyan

Copy link
Copy Markdown
Contributor
image

@serhiy-storchaka

Copy link
Copy Markdown
Member

I do not think that it is needed to add 'switch' to keywords.

Even if we only add one special case, it is worth to write more general code which will allow to add more keywords in future. See #146407 as example.

@ByteFlowing1337 ByteFlowing1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not think this change is correct.

Most of the previous PRs that improved SyntaxError message were implemented by modifying the parser rather than adding if statements in traceback.py. Also, if the entire keyword.softkwlist and switch are passed to _generate_suggestions() as candidates, it may cause unwanted side effects that are completely unrelated to the issue.

@zang-langyan

Copy link
Copy Markdown
Contributor Author

I do not think that it is needed to add 'switch' to keywords.

Even if we only add one special case, it is worth to write more general code which will allow to add more keywords in future. See #146407 as example.

Thank you for the reference, it is really a good example. I will look into it.

@zang-langyan zang-langyan changed the title gh-151128: Improve SyntaxError message for match gh-151128: Improve SyntaxError message for cross language keywords Jun 9, 2026
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