Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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 _PyImport_GetModuleDict().
  • Loading branch information
ericsnowcurrently committed Sep 14, 2017
commit 2ff5d7ca7e6d9ee13cda08467e29a00c5812ae80
3 changes: 3 additions & 0 deletions Include/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
);
#endif
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyImport_GetModuleDict(PyThreadState *tstate);
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
PyObject *name
Expand Down
22 changes: 20 additions & 2 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,30 @@ _PyImport_Fini(void)
/* Helper for sys */

PyObject *
PyImport_GetModuleDict(void)
_PyImport_GetModuleDict(PyThreadState *tstate)
{
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = tstate->interp;
if (interp->modules == NULL)
Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
return interp->modules;

/* We aren't ready to do this yet.
if (tstate->interp->sysdict == NULL)
Py_FatalError("_PyImport_GetModuleDict: no sys module!");

_Py_IDENTIFIER(modules);
PyObject *modules = _PyDict_GetItemId(tstate->interp->sysdict,
&PyId_modules);
if (modules == NULL)
Py_FatalError("lost sys.modules");
return modules;
*/
}

PyObject *
PyImport_GetModuleDict(void)
{
return _PyImport_GetModuleDict(PyThreadState_GET());
}


Expand Down