If the Py_LIMITED_API macro is defined, Py_BUILD_CORE,
Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros are now
undefined by Python.h.
Only undefine these 3 macros after including "exports.h" which uses
them to define PyAPI_FUNC(), PyAPI_DATA() and PyMODINIT_FUNC macros.
Remove hacks (undefine manually the 3 Py_BUILD_CORE macros) in
Modules/_testcapi/parts.h and Modules/_testclinic_limited.c.
:c:func:`!Py_TOLOWER`.
(Contributed by Victor Stinner in :gh:`108765`.)
+* If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!Py_BUILD_CORE`,
+ :c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!Py_BUILD_CORE_MODULE` macros
+ are now undefined by ``<Python.h>``.
+ (Contributed by Victor Stinner in :gh:`85283`.)
+
Deprecated
----------
# define Py_BUILD_CORE
#endif
-#if defined(Py_LIMITED_API) && defined(Py_BUILD_CORE)
-# error "Py_LIMITED_API is not compatible with Py_BUILD_CORE"
-#endif
-
/**************************************************************************
Symbols and macros to supply platform-independent interfaces to basic
#include "exports.h"
+#ifdef Py_LIMITED_API
+ // The internal C API must not be used with the limited C API: make sure
+ // that Py_BUILD_CORE macro is not defined in this case. These 3 macros are
+ // used by exports.h, so only undefine them afterwards.
+# undef Py_BUILD_CORE
+# undef Py_BUILD_CORE_BUILTIN
+# undef Py_BUILD_CORE_MODULE
+#endif
+
/* limits.h constants that may be missing */
#ifndef INT_MAX
--- /dev/null
+If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!Py_BUILD_CORE`,
+:c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!Py_BUILD_CORE_MODULE` macros
+are now undefined by ``<Python.h>``. Patch by Victor Stinner.