Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-28411: Isolate PyInterpreterState.modules #3575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Prev Previous commit
Next Next commit
Add _PyModule_Create2().
  • Loading branch information
ericsnowcurrently committed Sep 14, 2017
commit eb2d6f980179a61b7b667b3dafc13a591e3efef1
4 changes: 4 additions & 0 deletions Include/modsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);

PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
int apiver);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyModule_Create2(struct PyModuleDef*,
int apiver);
#endif

#ifdef Py_LIMITED_API
#define PyModule_Create(module) \
Expand Down
11 changes: 8 additions & 3 deletions Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ _add_methods_to_object(PyObject *module, PyObject *name, PyMethodDef *functions)

PyObject *
PyModule_Create2(struct PyModuleDef* module, int module_api_version)
{
_PyImport_EnsureInitialized(PyThreadState_GET()->interp);
return _PyModule_Create2(module, module_api_version);
}

PyObject *
_PyModule_Create2(struct PyModuleDef* module, int module_api_version)
{
const char* name;
PyModuleObject *m;
PyInterpreterState *interp = PyThreadState_Get()->interp;
if (interp->modules == NULL)
Py_FatalError("Python import machinery not initialized");

if (!PyModuleDef_Init(module))
return NULL;
name = module->m_name;
Expand Down