gh-99300: Use Py_NewRef() in Python/ directory (#99302)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Python/ directory.
This commit is contained in:
Victor Stinner 2022-11-10 09:03:39 +01:00 committed by GitHub
parent f883b7f8ee
commit d8f239d86e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 41 additions and 80 deletions

View file

@ -74,8 +74,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
ste->ste_table = st;
ste->ste_id = k; /* ste owns reference to k */
Py_INCREF(name);
ste->ste_name = name;
ste->ste_name = Py_NewRef(name);
ste->ste_symbols = NULL;
ste->ste_varnames = NULL;
@ -286,8 +285,7 @@ _PySymtable_Build(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
_PySymtable_Free(st);
return NULL;
}
Py_INCREF(filename);
st->st_filename = filename;
st->st_filename = Py_NewRef(filename);
st->st_future = future;
/* Setup recursion depth check counters */
@ -1949,8 +1947,7 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
return 0;
}
else {
store_name = name;
Py_INCREF(store_name);
store_name = Py_NewRef(name);
}
if (!_PyUnicode_EqualToASCIIString(name, "*")) {
int r = symtable_add_def(st, store_name, DEF_IMPORT, LOCATION(a));