2012-12-14 23:04:59 +08:00
|
|
|
/*
|
|
|
|
* C extensions module to test importing multiple modules from one compiled
|
|
|
|
* file (issue16421). This file defines 3 modules (_testimportmodule,
|
|
|
|
* foo, bar), only the first one is called the same as the compiled file.
|
|
|
|
*/
|
2023-10-17 08:27:15 +08:00
|
|
|
|
2023-11-20 21:52:00 +08:00
|
|
|
#include "pyconfig.h" // Py_GIL_DISABLED
|
|
|
|
#ifndef Py_GIL_DISABLED
|
2024-05-03 23:30:55 +08:00
|
|
|
# define Py_LIMITED_API 0x030d0000
|
2023-10-31 00:06:09 +08:00
|
|
|
#endif
|
2023-10-17 08:27:15 +08:00
|
|
|
|
|
|
|
#include <Python.h>
|
2012-12-14 23:04:59 +08:00
|
|
|
|
2024-05-03 23:30:55 +08:00
|
|
|
static PyModuleDef_Slot shared_slots[] = {
|
|
|
|
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
|
|
|
|
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
|
|
{0, NULL},
|
|
|
|
};
|
|
|
|
|
2012-12-14 23:04:59 +08:00
|
|
|
static struct PyModuleDef _testimportmultiple = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"_testimportmultiple",
|
|
|
|
"_testimportmultiple doc",
|
2024-05-03 23:30:55 +08:00
|
|
|
0,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
2024-05-03 23:30:55 +08:00
|
|
|
shared_slots,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-16 00:16:47 +08:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple(void)
|
2012-12-14 23:04:59 +08:00
|
|
|
{
|
2024-05-03 23:30:55 +08:00
|
|
|
return PyModuleDef_Init(&_testimportmultiple);
|
2012-12-14 23:04:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct PyModuleDef _foomodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2012-12-15 23:22:59 +08:00
|
|
|
"_testimportmultiple_foo",
|
|
|
|
"_testimportmultiple_foo doc",
|
2024-05-03 23:30:55 +08:00
|
|
|
0,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
2024-05-03 23:30:55 +08:00
|
|
|
shared_slots,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-16 00:16:47 +08:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple_foo(void)
|
2012-12-14 23:04:59 +08:00
|
|
|
{
|
2024-05-03 23:30:55 +08:00
|
|
|
return PyModuleDef_Init(&_foomodule);
|
2012-12-14 23:04:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct PyModuleDef _barmodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2012-12-15 23:22:59 +08:00
|
|
|
"_testimportmultiple_bar",
|
|
|
|
"_testimportmultiple_bar doc",
|
2024-05-03 23:30:55 +08:00
|
|
|
0,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
2024-05-03 23:30:55 +08:00
|
|
|
shared_slots,
|
2012-12-14 23:04:59 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-16 00:16:47 +08:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple_bar(void){
|
2024-05-03 23:30:55 +08:00
|
|
|
return PyModuleDef_Init(&_barmodule);
|
2012-12-14 23:04:59 +08:00
|
|
|
}
|