Skip to content

Commit ba55af2

Browse files
committed
gh-151128 Improve SyntaxError message for match
1 parent 29a920e commit ba55af2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/traceback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,14 +1486,17 @@ def _find_keyword_typos(self):
14861486
max_matches = 3
14871487
matches = []
14881488
if _suggestions is not None:
1489-
suggestion = _suggestions._generate_suggestions(keyword.kwlist, wrong_name)
1489+
suggestion = _suggestions._generate_suggestions(keyword.kwlist + keyword.softkwlist + ['switch'], wrong_name)
14901490
if suggestion:
14911491
matches.append(suggestion)
14921492
matches.extend(difflib.get_close_matches(wrong_name, keyword.kwlist, n=max_matches, cutoff=0.5))
14931493
matches = matches[:max_matches]
14941494
for suggestion in matches:
14951495
if not suggestion or suggestion == wrong_name:
14961496
continue
1497+
# semantic edge case
1498+
if suggestion == 'switch':
1499+
suggestion = 'match'
14971500
# Try to replace the token with the keyword
14981501
the_lines = error_lines.copy()
14991502
the_line = the_lines[start[0] - 1][:]

0 commit comments

Comments
 (0)