8000 gh-85283: If Py_LIMITED_API is defined, undefine Py_BUILD_CORE · python/cpython@105fce1 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 105fce1

Browse files
committed
gh-85283: If Py_LIMITED_API is defined, undefine Py_BUILD_CORE
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.
1 parent 01481f2 commit 105fce1

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@ Porting to Python 3.13
10751075
:c:func:`!Py_TOLOWER`.
10761076
(Contributed by Victor Stinner in :gh:`108765`.)
10771077

1078+
* If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`Py_BUILD_CORE`,
1079+
:c:macro:`Py_BUILD_CORE_BUILTIN` and :c:macro:`Py_BUILD_CORE_MODULE` macros
1080+
are now undefined by ``<Python.h>``.
1081+
(Contributed by Victor Stinner in :gh:`85283`.)
1082+
10781083
Deprecated
10791084
----------
10801085

Include/pyport.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
# define Py_BUILD_CORE
4949
#endif
5050

51-
#if defined(Py_LIMITED_API) && defined(Py_BUILD_CORE)
52-
# error "Py_LIMITED_API is not compatible with Py_BUILD_CORE"
53-
#endif
54-
5551

5652
/**************************************************************************
5753
Symbols and macros to supply platform-independent interfaces to basic
@@ -361,6 +357,15 @@ extern "C" {
361357

362358
#include "exports.h"
363359

360+
#ifdef Py_LIMITED_API
361+
// The internal C API must not be used with the limited C API: make sure
362+
// that Py_BUILD_CORE macro is not defined in this case. These 3 macros are
363+
// used by exports.h, so only undefine them afterwards.
364+
# undef Py_BUILD_CORE
365+
# undef Py_BUILD_CORE_BUILTIN
366+
# undef Py_BUILD_CORE_MODULE
367+
#endif
368+
364369
/* limits.h constants that may be missing */
365370

366371
#ifndef INT_MAX
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`Py_BUILD_CORE`,
2+
:c:macro:`Py_BUILD_CORE_BUILTIN` and :c:macro:`Py_BUILD_CORE_MODULE` macros
3+
are now undefined by ``<Python.h>``. Patch by Victor Stinner.

0 commit comments

Comments
 (0)
0