Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/test/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ def test_warn_missed_comma(self):
def check(test):
self.check_syntax_warning(test, msg)

msg=r'is not callable; perhaps you missed a comma\?'
msg=r'is not callable; did you miss a comma to separate sequence elements\?'
check('[(1, 2) (3, 4)]')
check('[(x, y) (3, 4)]')
check('[[1, 2] (3, 4)]')
Expand All @@ -1543,7 +1543,7 @@ def check(test):
check('[t"{x}" (3, 4)]')
check('[t"x={x}" (3, 4)]')

msg=r'is not subscriptable; perhaps you missed a comma\?'
msg=r'is not subscriptable; did you miss a comma to separate sequence elements\?'
check('[{1, 2} [i, j]]')
check('[{i for i in range(5)} [i, j]]')
check('[(i for i in range(5)) [i, j]]')
Expand All @@ -1557,7 +1557,7 @@ def check(test):
check('[t"{x}" [i, j]]')
check('[t"x={x}" [i, j]]')

msg=r'indices must be integers or slices, not tuple; perhaps you missed a comma\?'
msg=r'indices must be integers or slices, not tuple; did you miss a comma to separate sequence elements\?'
check('[(1, 2) [i, j]]')
check('[(x, y) [i, j]]')
check('[[1, 2] [i, j]]')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve syntax warning messages for missing commas in sequences. The messages now say "did you miss a comma to separate sequence elements?" instead of "perhaps you missed a comma?".
6 changes: 3 additions & 3 deletions Python/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ check_caller(compiler *c, expr_ty e)
case Interpolation_kind: {
location loc = LOC(e);
return _PyCompile_Warn(c, loc, "'%.200s' object is not callable; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
infer_type(e)->tp_name);
}
default:
Expand Down Expand Up @@ -3681,7 +3681,7 @@ check_subscripter(compiler *c, expr_ty e)
case Lambda_kind: {
location loc = LOC(e);
return _PyCompile_Warn(c, loc, "'%.200s' object is not subscriptable; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
infer_type(e)->tp_name);
}
default:
Expand Down Expand Up @@ -3716,7 +3716,7 @@ check_index(compiler *c, expr_ty e, expr_ty s)
location loc = LOC(e);
return _PyCompile_Warn(c, loc, "%.200s indices must be integers "
"or slices, not %.200s; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
infer_type(e)->tp_name,
index_type->tp_name);
}
Expand Down
Loading