Index: Lib/test/test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.27 diff -c -r1.27 test_scope.py *** Lib/test/test_scope.py 23 Jul 2002 19:04:00 -0000 1.27 --- Lib/test/test_scope.py 6 Aug 2003 12:33:26 -0000 *************** *** 522,524 **** --- 522,541 ---- return g f(4)() + + print "23. problems with erroneous input" + + # python bug #784075 gives this example: + + src="def g(a=None, b, c=lambda: None): g" + + # which is obviously bogus code, but tickled an abort trap in the + # symbol table code + + try: + exec src + except SyntaxError: + pass + else: + raise TestFailed("non-default argument following default " + "argument didn't raise") Index: Lib/test/output/test_scope =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_scope,v retrieving revision 1.12 diff -c -r1.12 test_scope *** Lib/test/output/test_scope 20 Apr 2002 04:51:39 -0000 1.12 --- Lib/test/output/test_scope 6 Aug 2003 12:33:26 -0000 *************** *** 22,24 **** --- 22,25 ---- 20. eval and exec with free variables 21. list comprehension with local variables 22. eval with free variables + 23. problems with erroneous input Index: Python/compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.291 diff -c -r2.291 compile.c *** Python/compile.c 15 Jul 2003 20:23:26 -0000 2.291 --- Python/compile.c 6 Aug 2003 12:33:27 -0000 *************** *** 3709,3718 **** t = TYPE(CHILD(n, i)); } else { ! /* Treat "(a=1, b)" as an error */ ! if (ndefs) ! com_error(c, PyExc_SyntaxError, ! "non-default argument follows default argument"); } if (t != COMMA) break; --- 3709,3717 ---- t = TYPE(CHILD(n, i)); } else { ! /* we check for non-default argument following default ! argument in the symtable phase now */ ! assert(ndefs == 0); } if (t != COMMA) break; *************** *** 5461,5466 **** --- 5460,5466 ---- { node *c; int i; + int ndefs = 0; if (TYPE(n) == parameters) { n = CHILD(n, 1); *************** *** 5473,5480 **** if (TYPE(c) == STAR || TYPE(c) == DOUBLESTAR) { break; } ! if (i > 0 && (TYPE(CHILD(n, i - 1)) == EQUAL)) ! symtable_node(st, CHILD(n, i)); } } --- 5473,5489 ---- if (TYPE(c) == STAR || TYPE(c) == DOUBLESTAR) { break; } ! if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) { ! ndefs++; ! symtable_node(st, CHILD(n, i+2)); ! i += 2; ! } ! else if (ndefs > 0) { ! PyErr_SetString(PyExc_SyntaxError, ! "non-default argument follows default argument"); ! st->st_errors++; ! return; ! } } }