mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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:
parent
403a574b00
commit
193a2b2eaa
2 changed files with 2 additions and 3 deletions
|
@ -1382,8 +1382,7 @@ create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec)
|
|||
if (_PyUnicode_EqualToASCIIString(name, p->name)) {
|
||||
if (p->initfunc == NULL) {
|
||||
/* Cannot re-init internal module ("sys" or "builtins") */
|
||||
mod = PyImport_AddModuleObject(name);
|
||||
return Py_XNewRef(mod);
|
||||
return import_add_module(tstate, name);
|
||||
}
|
||||
mod = _PyImport_InitFunc_TrampolineCall(*p->initfunc);
|
||||
if (mod == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue