diff Python/compile.c @ 30488:b0c3d986f63f legacy-trunk

Fix SF bug [ 808594 ] leak on lambda with duplicate arguments error. Refactor code so that one helper routine sets error location and increments st_errors. Bug fix candidate.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Mon, 22 Sep 2003 04:26:44 +0000
parents e8147f841a4a
children 3b59fa5d25b1
line wrap: on
line diff
--- a/Python/compile.c	Mon Sep 22 01:16:48 2003 +0000
+++ b/Python/compile.c	Mon Sep 22 04:26:44 2003 +0000
@@ -4778,6 +4778,16 @@
 }
 
 static int
+symtable_error(struct symtable *st, int lineno)
+{
+	if (lineno == 0)
+		lineno = st->st_cur->ste_lineno;
+	PyErr_SyntaxLocation(st->st_filename, lineno);
+	st->st_errors++;
+	return -1;
+}
+
+static int
 symtable_load_symbols(struct compiling *c)
 {
 	struct symtable *st = c->c_symtable;
@@ -4835,9 +4845,7 @@
 			if (flags & DEF_PARAM) {
 				PyErr_Format(PyExc_SyntaxError, LOCAL_GLOBAL,
 					     PyString_AS_STRING(name));
-				PyErr_SyntaxLocation(st->st_filename, 
-						   ste->ste_lineno);
-				st->st_errors++;
+				symtable_error(st, 0);
 				goto fail;
 			}
 			if (PyDict_SetItem(c->c_globals, name, Py_None) < 0)
@@ -5190,9 +5198,7 @@
 	    if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
 		    PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
 				 PyString_AsString(name));
-		    PyErr_SyntaxLocation(st->st_filename,
-				       st->st_cur->ste_lineno);
-		    return -1;
+		    return symtable_error(st, 0);
 	    }
 	    val |= flag;
 	} else
@@ -5589,9 +5595,7 @@
 				PyErr_Format(PyExc_SyntaxError,
 				     "name '%.400s' is local and global",
 					     name);
-				PyErr_SyntaxLocation(st->st_filename,
-						   st->st_cur->ste_lineno);
-				st->st_errors++;
+				symtable_error(st, 0);
 				return;
 			}
 			else {
@@ -5651,9 +5655,7 @@
 			if (n->n_lineno >= st->st_future->ff_last_lineno) {
 				PyErr_SetString(PyExc_SyntaxError,
 						LATE_FUTURE);
- 				PyErr_SyntaxLocation(st->st_filename,
-						   n->n_lineno);
-				st->st_errors++;
+				symtable_error(st, n->n_lineno);
 				return;
 			}
 		}
@@ -5747,9 +5749,8 @@
 			if (strcmp(STR(tmp), "__debug__") == 0) {
 				PyErr_SetString(PyExc_SyntaxError, 
 						ASSIGN_DEBUG);
-				PyErr_SyntaxLocation(st->st_filename,
-						     n->n_lineno);
-				st->st_errors++;
+				symtable_error(st, n->n_lineno);
+				return;
 			}
 			symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
 		}