Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add PyInterpreterState.sysdict_copy.
  • Loading branch information
ericsnowcurrently committed Mar 13, 2023
commit f6a45557e764f81908e18a49ea15a2a83514eaaa
1 change: 1 addition & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct _is {

PyObject *dict; /* Stores per-interpreter state */

PyObject *sysdict_copy;
PyObject *builtins_copy;
// Initialized to _PyEval_EvalFrameDefault().
_PyFrameEvalFunction eval_frame;
Expand Down
1 change: 1 addition & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
assert(interp->imports.importlib == NULL);
assert(interp->imports.import_func == NULL);

Py_CLEAR(interp->sysdict_copy);
Py_CLEAR(interp->builtins_copy);
Py_CLEAR(interp->dict);
#ifdef HAVE_FORK
Expand Down
5 changes: 5 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,11 @@ _PySys_Create(PyThreadState *tstate, PyObject **sysmod_p)
}
interp->sysdict = Py_NewRef(sysdict);

interp->sysdict_copy = PyDict_Copy(sysdict);
if (interp->sysdict_copy == NULL) {
goto error;
}

if (PyDict_SetItemString(sysdict, "modules", modules) < 0) {
goto error;
}
Expand Down