summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2003-09-22 04:41:21 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2003-09-22 04:41:21 (GMT)
commit7fe9f6da1882b96a4762cd4964ad02b07bae2eee (patch)
tree9efaa99432a48879f959778fd22796c4715c0759 /Python
parenta758b7615c341def4ae38b2bc0df757e788e7de0 (diff)
downloadcpython-7fe9f6da1882b96a4762cd4964ad02b07bae2eee.zip
cpython-7fe9f6da1882b96a4762cd4964ad02b07bae2eee.tar.gz
cpython-7fe9f6da1882b96a4762cd4964ad02b07bae2eee.tar.bz2
Backport fix for SF808594: leak on lambda with duplicate arguments.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 9ac0032..f2e04b0 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -4770,6 +4770,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)
{
struct symtable *st = c->c_symtable;
@@ -4827,9 +4837,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)
@@ -5182,9 +5190,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
@@ -5581,9 +5587,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 {
@@ -5643,9 +5647,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;
}
}
@@ -5739,9 +5741,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);
}