gh-111789: Use PyDict_GetItemRef() in Python/symtable.c (gh-112084)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:55:30 +02:00 committed by GitHub
parent aa438bdd6d
commit befbad3663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -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