gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)

Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
and Py_XNewRef().
This commit is contained in:
Victor Stinner 2022-11-16 18:34:24 +01:00 committed by GitHub
parent 19c1462e8d
commit 8211cf5d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 40 additions and 74 deletions

View file

@ -373,17 +373,17 @@ PySymtable_Lookup(struct symtable *st, void *key)
if (k == NULL)
return NULL;
v = PyDict_GetItemWithError(st->st_blocks, k);
Py_DECREF(k);
if (v) {
assert(PySTEntry_Check(v));
Py_INCREF(v);
}
else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_KeyError,
"unknown symbol table entry");
}
Py_DECREF(k);
return (PySTEntryObject *)v;
return (PySTEntryObject *)Py_XNewRef(v);
}
long