diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-09-22 04:42:17 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-09-22 04:42:17 +0000 |
commit | e7d86ed4025b7c9f4102757ea51e28c627d6fabd (patch) | |
tree | d49e9b9efbde59f5918883c87ec9c779ef4713f1 | |
parent | db252e0092b2b70c4b2ada68df3f6cd4bd035d6b (diff) | |
download | cpython-e7d86ed4025b7c9f4102757ea51e28c627d6fabd.tar.gz |
Backport fix for SF808594: leak on lambda with duplicate arguments.
-rw-r--r-- | Python/compile.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/Python/compile.c b/Python/compile.c index f803c68d91..1788509141 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4549,6 +4549,16 @@ symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste, } 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) { static PyObject *implicit = NULL; @@ -4612,9 +4622,7 @@ symtable_load_symbols(struct compiling *c) 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) @@ -4959,9 +4967,7 @@ symtable_add_def_o(struct symtable *st, PyObject *dict, 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 @@ -5358,9 +5364,7 @@ symtable_global(struct symtable *st, node *n) 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 { @@ -5420,9 +5424,7 @@ symtable_import(struct symtable *st, node *n) 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; } } @@ -5515,9 +5517,8 @@ symtable_assign(struct symtable *st, node *n, int def_flag) 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); } |