Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29d38cd

Browse files
committed
Treat def f(a, b=1, c): ... as an error (missing default for c)
instead of silently supplying a default of None fore c.
1 parent b7c6131 commit 29d38cd

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

Python/compile.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,13 +2721,10 @@ com_argdefs(c, n)
27212721
t = TYPE(CHILD(n, i));
27222722
}
27232723
else {
2724-
/* Treat "(a=1, b)" as "(a=1, b=None)" */
2725-
if (ndefs) {
2726-
com_addoparg(c, LOAD_CONST,
2727-
com_addconst(c, Py_None));
2728-
com_push(c, 1);
2729-
ndefs++;
2730-
}
2724+
/* Treat "(a=1, b)" as an error */
2725+
if (ndefs)
2726+
com_error(c, PyExc_SyntaxError,
2727+
"Missing parameter default value");
27312728
}
27322729
if (t != COMMA)
27332730
break;

0 commit comments

Comments
 (0)