Skip to content

Commit 9a72b01

Browse files
committed
Workaround setuptools bug
1 parent 9177bc6 commit 9a72b01

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎tests/test_pythoncapi_compat_cext.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,14 +2670,28 @@ static PySlot module_slots[] = {
26702670
{0, 0, {0}, {0}}
26712671
};
26722672

2673-
#define INIT_FUNC CONCAT(PyModExport_, MODULE_NAME)
2673+
#define EXPORT_FUNC CONCAT(PyModExport_, MODULE_NAME)
26742674

26752675
PyMODEXPORT_FUNC
2676-
INIT_FUNC(void)
2676+
EXPORT_FUNC(void)
26772677
{
26782678
return module_slots;
26792679
}
26802680

2681+
#ifdef MS_WINDOWS
2682+
#define INIT_FUNC CONCAT(PyInit_, MODULE_NAME)
2683+
2684+
// Workaround for https://github.com/pypa/distutils/issues/387
2685+
// https://docs.python.org/3.16/howto/abi3t-migration.html#module-export-hook
2686+
PyMODINIT_FUNC
2687+
INIT_FUNC(void)
2688+
{
2689+
PyErr_SetString(PyExc_SystemError,
2690+
"PyInit_* called for module with PyModExport_*");
2691+
return NULL;
2692+
}
2693+
#endif
2694+
26812695
#else
26822696

26832697
static PyModuleDef_Slot module_slots[] = {

0 commit comments

Comments
 (0)