mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-132775: Drop PyUnstable_InterpreterState_GetMainModule() (gh-132978)
We replace it with _Py_GetMainModule(), and add _Py_CheckMainModule(), but both in the internal-only C-API. We also add _PyImport_GetModulesRef(), which is the equivalent of _PyImport_GetModules(), but which increfs before the lock is released. This is used by a later change related to pickle and handling __main__.
This commit is contained in:
parent
c17238251f
commit
fe462f5a91
7 changed files with 53 additions and 20 deletions
|
|
@ -153,6 +153,20 @@ _PyImport_GetModules(PyInterpreterState *interp)
|
|||
return MODULES(interp);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyImport_GetModulesRef(PyInterpreterState *interp)
|
||||
{
|
||||
_PyImport_AcquireLock(interp);
|
||||
PyObject *modules = MODULES(interp);
|
||||
if (modules == NULL) {
|
||||
/* The interpreter hasn't been initialized yet. */
|
||||
modules = Py_None;
|
||||
}
|
||||
Py_INCREF(modules);
|
||||
_PyImport_ReleaseLock(interp);
|
||||
return modules;
|
||||
}
|
||||
|
||||
void
|
||||
_PyImport_ClearModules(PyInterpreterState *interp)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue