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.
This commit is contained in:
parent
125188cabf
commit
9832613beb
|
@ -4777,6 +4777,16 @@ symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static int
|
||||||
symtable_load_symbols(struct compiling *c)
|
symtable_load_symbols(struct compiling *c)
|
||||||
{
|
{
|
||||||
|
@ -4835,9 +4845,7 @@ symtable_load_symbols(struct compiling *c)
|
||||||
if (flags & DEF_PARAM) {
|
if (flags & DEF_PARAM) {
|
||||||
PyErr_Format(PyExc_SyntaxError, LOCAL_GLOBAL,
|
PyErr_Format(PyExc_SyntaxError, LOCAL_GLOBAL,
|
||||||
PyString_AS_STRING(name));
|
PyString_AS_STRING(name));
|
||||||
PyErr_SyntaxLocation(st->st_filename,
|
symtable_error(st, 0);
|
||||||
ste->ste_lineno);
|
|
||||||
st->st_errors++;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (PyDict_SetItem(c->c_globals, name, Py_None) < 0)
|
if (PyDict_SetItem(c->c_globals, name, Py_None) < 0)
|
||||||
|
@ -5190,9 +5198,7 @@ symtable_add_def_o(struct symtable *st, PyObject *dict,
|
||||||
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
|
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
|
||||||
PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
|
PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
|
||||||
PyString_AsString(name));
|
PyString_AsString(name));
|
||||||
PyErr_SyntaxLocation(st->st_filename,
|
return symtable_error(st, 0);
|
||||||
st->st_cur->ste_lineno);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
val |= flag;
|
val |= flag;
|
||||||
} else
|
} else
|
||||||
|
@ -5589,9 +5595,7 @@ symtable_global(struct symtable *st, node *n)
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
PyErr_Format(PyExc_SyntaxError,
|
||||||
"name '%.400s' is local and global",
|
"name '%.400s' is local and global",
|
||||||
name);
|
name);
|
||||||
PyErr_SyntaxLocation(st->st_filename,
|
symtable_error(st, 0);
|
||||||
st->st_cur->ste_lineno);
|
|
||||||
st->st_errors++;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -5651,9 +5655,7 @@ symtable_import(struct symtable *st, node *n)
|
||||||
if (n->n_lineno >= st->st_future->ff_last_lineno) {
|
if (n->n_lineno >= st->st_future->ff_last_lineno) {
|
||||||
PyErr_SetString(PyExc_SyntaxError,
|
PyErr_SetString(PyExc_SyntaxError,
|
||||||
LATE_FUTURE);
|
LATE_FUTURE);
|
||||||
PyErr_SyntaxLocation(st->st_filename,
|
symtable_error(st, n->n_lineno);
|
||||||
n->n_lineno);
|
|
||||||
st->st_errors++;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5747,9 +5749,8 @@ symtable_assign(struct symtable *st, node *n, int def_flag)
|
||||||
if (strcmp(STR(tmp), "__debug__") == 0) {
|
if (strcmp(STR(tmp), "__debug__") == 0) {
|
||||||
PyErr_SetString(PyExc_SyntaxError,
|
PyErr_SetString(PyExc_SyntaxError,
|
||||||
ASSIGN_DEBUG);
|
ASSIGN_DEBUG);
|
||||||
PyErr_SyntaxLocation(st->st_filename,
|
symtable_error(st, n->n_lineno);
|
||||||
n->n_lineno);
|
return;
|
||||||
st->st_errors++;
|
|
||||||
}
|
}
|
||||||
symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
|
symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue