Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit097c71b

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 nowundefined by Python.h.Only undefine these 3 macros after including "exports.h" which usesthem to define PyAPI_FUNC(), PyAPI_DATA() and PyMODINIT_FUNC macros.Remove hacks (undefine manually the 3 Py_BUILD_CORE macros) inModules/_testcapi/parts.h and Modules/_testclinic_limited.c.
1 parent01481f2 commit097c71b

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
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
#definePy_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.

‎Modules/_testcapi/parts.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44
// Always enable assertions
55
#undef NDEBUG
66

7-
// The _testcapi extension tests the public C API: header files in Include/ and
8-
// Include/cpython/ directories. The internal C API must not be tested by
9-
// _testcapi: use _testinternalcapi for that.
10-
//
11-
// _testcapi C files can built with the Py_BUILD_CORE_BUILTIN macro defined if
12-
// one of the Modules/Setup files asks to build _testcapi as "static"
13-
// (gh-109723).
14-
//
15-
// The Visual Studio projects builds _testcapi with Py_BUILD_CORE_MODULE.
16-
#undef Py_BUILD_CORE_MODULE
17-
#undef Py_BUILD_CORE_BUILTIN
18-
197
#include"Python.h"
208

219
#ifdefPy_BUILD_CORE

‎Modules/_testclinic_limited.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// _testclinic_limited can built with the Py_BUILD_CORE_BUILTIN macro defined
2-
// if one of the Modules/Setup files asks to build it as "static" (gh-109723).
3-
#undef Py_BUILD_CORE
4-
#undef Py_BUILD_CORE_MODULE
5-
#undef Py_BUILD_CORE_BUILTIN
6-
71
// For now, only limited C API 3.13 is supported
82
#definePy_LIMITED_API 0x030d0000
93

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp