summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/whatsnew/3.13.rst5
-rw-r--r--Include/pyport.h13
-rw-r--r--Misc/NEWS.d/next/C API/2023-10-11-17-29-52.gh-issue-85283.OsqIBF.rst3
3 files changed, 17 insertions, 4 deletions
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index bbc1fec..b0a0d89 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -1075,6 +1075,11 @@ Porting to Python 3.13
: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
----------
diff --git a/Include/pyport.h b/Include/pyport.h
index 40d580a..d30fcd7 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -48,10 +48,6 @@
# 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
@@ -361,6 +357,15 @@ extern "C" {
#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
diff --git a/Misc/NEWS.d/next/C API/2023-10-11-17-29-52.gh-issue-85283.OsqIBF.rst b/Misc/NEWS.d/next/C API/2023-10-11-17-29-52.gh-issue-85283.OsqIBF.rst
new file mode 100644
index 0000000..c89a029
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2023-10-11-17-29-52.gh-issue-85283.OsqIBF.rst
@@ -0,0 +1,3 @@
+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.