]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Treat def f(a, b=1, c): ... as an error (missing default for c)
authorGuido van Rossum <guido@python.org>
Fri, 2 Oct 1998 13:41:54 +0000 (13:41 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 2 Oct 1998 13:41:54 +0000 (13:41 +0000)
instead of silently supplying a default of None fore c.

Python/compile.c

index afe330b5c93b5b4b1481b10fa69cba7a298770af..ef88eda20aa111f91454ac92bfc926dd83205da9 100644 (file)
@@ -2721,13 +2721,10 @@ com_argdefs(c, n)
                        t = TYPE(CHILD(n, i));
                }
                else {
-                       /* Treat "(a=1, b)" as "(a=1, b=None)" */
-                       if (ndefs) {
-                               com_addoparg(c, LOAD_CONST,
-                                            com_addconst(c, Py_None));
-                               com_push(c, 1);
-                               ndefs++;
-                       }
+                       /* Treat "(a=1, b)" as an error */
+                       if (ndefs)
+                               com_error(c, PyExc_SyntaxError,
+                                         "Missing parameter default value");
                }
                if (t != COMMA)
                        break;