Skip to content

Commit f68aa92

Browse files
committed
preserve constant tuple warnings
1 parent 5c822c7 commit f68aa92

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Python/codegen.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,11 +1693,26 @@ codegen_typealias(compiler *c, stmt_ty s)
16931693
return SUCCESS;
16941694
}
16951695

1696+
static bool
1697+
is_const_tuple(asdl_expr_seq *elts)
1698+
{
1699+
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
1700+
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
1701+
if (e->kind != Constant_kind) {
1702+
return false;
1703+
}
1704+
}
1705+
return true;
1706+
}
1707+
16961708
/* Return false if the expression is a constant value except named singletons.
16971709
Return true otherwise. */
16981710
static bool
16991711
check_is_arg(expr_ty e)
17001712
{
1713+
if (e->kind == Tuple_kind) {
1714+
return !is_const_tuple(e->v.Tuple.elts);
1715+
}
17011716
if (e->kind != Constant_kind) {
17021717
return true;
17031718
}

0 commit comments

Comments
 (0)