python/dist/src/Python compile.c,2.291,2.292

Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv11600 Modified Files: compile.c Log Message: Fix for SF bug [ 784075 ] Fatal Python error: unknown scope Make sure the inner function is not compiled when there is a syntax error in the default arguments. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.291 retrieving revision 2.292 diff -C2 -d -r2.291 -r2.292 *** compile.c 15 Jul 2003 20:23:26 -0000 2.291 --- compile.c 28 Aug 2003 14:42:14 -0000 2.292 *************** *** 3667,3674 **** } static int com_argdefs(struct compiling *c, node *n) { ! int i, nch, nargs, ndefs; if (TYPE(n) == lambdef) { /* lambdef: 'lambda' [varargslist] ':' test */ --- 3667,3680 ---- } + /* Return the number of default values in the argument list. + + If a non-default argument follows a default argument, set an + exception and return -1. + */ + static int com_argdefs(struct compiling *c, node *n) { ! int i, nch, ndefs; if (TYPE(n) == lambdef) { /* lambdef: 'lambda' [varargslist] ':' test */ *************** *** 3687,3691 **** fpdef ['=' test] (',' fpdef ['=' test])* [','] */ nch = NCH(n); - nargs = 0; ndefs = 0; for (i = 0; i < nch; i++) { --- 3693,3696 ---- *************** *** 3694,3698 **** TYPE(CHILD(n, i)) == DOUBLESTAR) break; - nargs++; i++; if (i >= nch) --- 3699,3702 ---- *************** *** 3711,3717 **** else { /* Treat "(a=1, b)" as an error */ ! if (ndefs) com_error(c, PyExc_SyntaxError, "non-default argument follows default argument"); } if (t != COMMA) --- 3715,3723 ---- else { /* Treat "(a=1, b)" as an error */ ! if (ndefs) { com_error(c, PyExc_SyntaxError, "non-default argument follows default argument"); + return -1; + } } if (t != COMMA) *************** *** 3728,3731 **** --- 3734,3739 ---- REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ ndefs = com_argdefs(c, n); + if (ndefs < 0) + return; symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n), n->n_lineno);
participants (1)
-
jhylton@users.sourceforge.net