2012-12-14 11:04:59 -04: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-16 21:27:15 -03:00
|
|
|
|
2023-11-20 09:52:00 -04:00
|
|
|
#include "pyconfig.h" // Py_GIL_DISABLED
|
|
|
|
#ifndef Py_GIL_DISABLED
|
2024-05-03 12:30:55 -03:00
|
|
|
# define Py_LIMITED_API 0x030d0000
|
2023-10-30 13:06:09 -03:00
|
|
|
#endif
|
2023-10-16 21:27:15 -03:00
|
|
|
|
|
|
|
#include <Python.h>
|
2012-12-14 11:04:59 -04:00
|
|
|
|
2024-05-03 12:30:55 -03: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 11:04:59 -04:00
|
|
|
static struct PyModuleDef _testimportmultiple = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"_testimportmultiple",
|
|
|
|
"_testimportmultiple doc",
|
2024-05-03 12:30:55 -03:00
|
|
|
0,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
2024-05-03 12:30:55 -03:00
|
|
|
shared_slots,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-15 12:16:47 -04:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple(void)
|
2012-12-14 11:04:59 -04:00
|
|
|
{
|
2024-05-03 12:30:55 -03:00
|
|
|
return PyModuleDef_Init(&_testimportmultiple);
|
2012-12-14 11:04:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct PyModuleDef _foomodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2012-12-15 11:22:59 -04:00
|
|
|
"_testimportmultiple_foo",
|
|
|
|
"_testimportmultiple_foo doc",
|
2024-05-03 12:30:55 -03:00
|
|
|
0,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
2024-05-03 12:30:55 -03:00
|
|
|
shared_slots,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-15 12:16:47 -04:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple_foo(void)
|
2012-12-14 11:04:59 -04:00
|
|
|
{
|
2024-05-03 12:30:55 -03:00
|
|
|
return PyModuleDef_Init(&_foomodule);
|
2012-12-14 11:04:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct PyModuleDef _barmodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2012-12-15 11:22:59 -04:00
|
|
|
"_testimportmultiple_bar",
|
|
|
|
"_testimportmultiple_bar doc",
|
2024-05-03 12:30:55 -03:00
|
|
|
0,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
2024-05-03 12:30:55 -03:00
|
|
|
shared_slots,
|
2012-12-14 11:04:59 -04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-12-15 12:16:47 -04:00
|
|
|
PyMODINIT_FUNC PyInit__testimportmultiple_bar(void){
|
2024-05-03 12:30:55 -03:00
|
|
|
return PyModuleDef_Init(&_barmodule);
|
2012-12-14 11:04:59 -04:00
|
|
|
}
|