mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
This commit is contained in:
parent
a180b007d9
commit
a24107b04c
31 changed files with 538 additions and 242 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue