summaryrefslogtreecommitdiffstats
path: root/Python/symtable.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/symtable.c')
-rw-r--r--Python/symtable.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Python/symtable.c b/Python/symtable.c
index cade304..6e2df2f 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -359,12 +359,12 @@ PySymtable_Lookup(struct symtable *st, void *key)
k = PyLong_FromVoidPtr(key);
if (k == NULL)
return NULL;
- v = PyDict_GetItem(st->st_blocks, k);
+ v = PyDict_GetItemWithError(st->st_blocks, k);
if (v) {
assert(PySTEntry_Check(v));
Py_INCREF(v);
}
- else {
+ else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_KeyError,
"unknown symbol table entry");
}
@@ -637,7 +637,7 @@ update_symbols(PyObject *symbols, PyObject *scopes,
}
while ((name = PyIter_Next(itr))) {
- v = PyDict_GetItem(symbols, name);
+ v = PyDict_GetItemWithError(symbols, name);
/* Handle symbol that already exists in this scope */
if (v) {
@@ -662,6 +662,9 @@ update_symbols(PyObject *symbols, PyObject *scopes,
Py_DECREF(name);
continue;
}
+ else if (PyErr_Occurred()) {
+ goto error;
+ }
/* Handle global symbol */
if (bound && !PySet_Contains(bound, name)) {
Py_DECREF(name);
@@ -991,7 +994,7 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s
if (!mangled)
return 0;
dict = ste->ste_symbols;
- if ((o = PyDict_GetItem(dict, mangled))) {
+ if ((o = PyDict_GetItemWithError(dict, mangled))) {
val = PyLong_AS_LONG(o);
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
/* Is it better to use 'mangled' or 'name' here? */
@@ -1002,8 +1005,13 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s
goto error;
}
val |= flag;
- } else
+ }
+ else if (PyErr_Occurred()) {
+ goto error;
+ }
+ else {
val = flag;
+ }
o = PyLong_FromLong(val);
if (o == NULL)
goto error;