Skip to content

Commit 412f771

Browse files
committed
Try to fix Windows 3.9
1 parent faeb2c2 commit 412f771

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎pythoncapi_compat.h‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,10 @@ PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
472472
// bpo-40024 added PyModule_AddType() to Python 3.9.0a5
473473
// On Windows, PyModule_AddType() was added to limited C API 3.9.
474474
#if (PY_VERSION_HEX < 0x030900A5 \
475-
|| (defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x03090000))
476-
static inline int PyModule_AddType(PyObject *module, PyTypeObject *type)
475+
|| (defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x03090000) \
476+
|| (defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000 && defined(MS_WINDOWS)))
477+
static inline int
478+
_PythonCAPICompat_Module_AddType(PyObject *module, PyTypeObject *type)
477479
{
478480
#ifndef Py_LIMITED_API
479481
const char *name, *dot;
@@ -515,6 +517,17 @@ static inline int PyModule_AddType(PyObject *module, PyTypeObject *type)
515517
return res;
516518
#endif
517519
}
520+
521+
#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000 && defined(MS_WINDOWS)
522+
// On Python 3.9, PyModule_AddType() is part of the limited C API,
523+
// but the function is not exported in the stable ABI.
524+
# define PyModule_AddType _PythonCAPICompat_Module_AddType
525+
#else
526+
static inline int PyModule_AddType(PyObject *module, PyTypeObject *type)
527+
{
528+
return _PythonCAPICompat_Module_AddType(module, type);
529+
}
530+
#endif
518531
#endif
519532

520533

0 commit comments

Comments
 (0)