8000 gh-111789: Use PyDict_GetItemRef() in Python/symtable.c (gh-112084) · python/cpython@befbad3 · GitHub
[go: up one dir, main page]

Skip to content

Commit befbad3

Browse files
gh-111789: Use PyDict_GetItemRef() in Python/symtable.c (gh-112084)
1 parent aa438bd commit befbad3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Python/symtable.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,14 @@ _PySymtable_Lookup(struct symtable *st, void *key)
497497
k = PyLong_FromVoidPtr(key);
498498
if (k == NULL)
499499
return NULL;
500-
v = PyDict_GetItemWithError(st->st_blocks, k);
501-
Py_DECREF(k);
502-
503-
if (v) {
504-
assert(PySTEntry_Check(v));
505-
}
506-
else if (!PyErr_Occurred()) {
500+
if (PyDict_GetItemRef(st->st_blocks, k, &v) == 0) {
507501
PyErr_SetString(PyExc_KeyError,
508502
"unknown symbol table entry");
509503
}
504+
Py_DECREF(k);
510505

511-
return (PySTEntryObject *)Py_XNewRef(v);
506+
assert(v == NULL || PySTEntry_Check(v));
507+
return (PySTEntryObject *)v;
512508
}
513509

514510
long

0 commit comments

Comments
 (0)
0