Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Python/symtable.c (python…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored and aisk committed Feb 11, 2024
1 parent 7af6836 commit 1a2df4a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,14 @@ _PySymtable_Lookup(struct symtable *st, void *key)
k = PyLong_FromVoidPtr(key);
if (k == NULL)
return NULL;
v = PyDict_GetItemWithError(st->st_blocks, k);
Py_DECREF(k);

if (v) {
assert(PySTEntry_Check(v));
}
else if (!PyErr_Occurred()) {
if (PyDict_GetItemRef(st->st_blocks, k, &v) == 0) {
PyErr_SetString(PyExc_KeyError,
"unknown symbol table entry");
}
Py_DECREF(k);

return (PySTEntryObject *)Py_XNewRef(v);
assert(v == NULL || PySTEntry_Check(v));
return (PySTEntryObject *)v;
}

long
Expand Down

0 comments on commit 1a2df4a

Please sign in to comment.