mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-36124: Add PyInterpreterState.dict. (gh-12132)
This commit is contained in:
parent
c11183cdcf
commit
d2fdd1fedf
5 changed files with 40 additions and 2 deletions
|
@ -224,6 +224,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
|
|||
Py_CLEAR(interp->builtins_copy);
|
||||
Py_CLEAR(interp->importlib);
|
||||
Py_CLEAR(interp->import_func);
|
||||
Py_CLEAR(interp->dict);
|
||||
#ifdef HAVE_FORK
|
||||
Py_CLEAR(interp->before_forkers);
|
||||
Py_CLEAR(interp->after_forkers_parent);
|
||||
|
@ -462,6 +463,19 @@ _PyInterpreterState_GetMainModule(PyInterpreterState *interp)
|
|||
return PyMapping_GetItemString(interp->modules, "__main__");
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyInterpreterState_GetDict(PyInterpreterState *interp)
|
||||
{
|
||||
if (interp->dict == NULL) {
|
||||
interp->dict = PyDict_New();
|
||||
if (interp->dict == NULL) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
/* Returning NULL means no per-interpreter dict is available. */
|
||||
return interp->dict;
|
||||
}
|
||||
|
||||
/* Default implementation for _PyThreadState_GetFrame */
|
||||
static struct _frame *
|
||||
threadstate_getframe(PyThreadState *self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue