gh-105922: Use PyImport_AddModuleRef() function (#105999)

Replace PyImport_AddModuleObject() + Py_XNewRef() with
PyImport_AddModuleRef() to get directly a strong reference.
This commit is contained in:
Victor Stinner 2023-06-23 00:04:39 +02:00 committed by GitHub
parent 403a574b00
commit 193a2b2eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View file

@ -276,7 +276,7 @@ PyRun_InteractiveOneObjectEx(FILE *fp, PyObject *filename,
return parse_res;
}
PyObject *main_module = Py_XNewRef(PyImport_AddModuleObject(&_Py_ID(__main__)));
PyObject *main_module = PyImport_AddModuleRef("__main__");
if (main_module == NULL) {
_PyArena_Free(arena);
return -1;