Skip to content

Commit 7835449

Browse files
committed
Move Py_BUILD_CORE undefines, and include exports.h directly from Python.h
1 parent 247bd46 commit 7835449

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

Include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ __pragma(warning(disable: 4201))
6666

6767
// Include Python header files
6868
#include "pyport.h"
69+
#include "exports.h"
6970
#include "pymacro.h"
7071
#include "pymath.h"
7172
#include "pymem.h"

Include/exports.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define Py_LOCAL_SYMBOL
3737
#endif
3838
/* module init functions outside the core must be exported */
39-
#if defined(Py_BUILD_CORE)
39+
#if defined(_PyEXPORTS_CORE)
4040
#define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL
4141
#else
4242
#define _PyINIT_EXPORTED_SYMBOL __declspec(dllexport)
@@ -64,13 +64,13 @@
6464
/* only get special linkage if built as shared or platform is Cygwin */
6565
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
6666
# if defined(HAVE_DECLSPEC_DLL)
67-
# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
67+
# if defined(_PyEXPORTS_CORE) && !defined(_PyEXPORTS_CORE_MODULE)
6868
/* module init functions inside the core need no external linkage */
6969
/* except for Cygwin to handle embedding */
7070
# if !defined(__CYGWIN__)
7171
# define _PyINIT_FUNC_DECLSPEC
7272
# endif /* __CYGWIN__ */
73-
# else /* Py_BUILD_CORE */
73+
# else /* _PyEXPORTS_CORE */
7474
/* Building an extension module, or an embedded situation */
7575
/* public Python functions and data are imported */
7676
/* Under Cygwin, auto-import functions to prevent compilation */
@@ -80,7 +80,7 @@
8080
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
8181
# endif /* !__CYGWIN__ */
8282
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
83-
# endif /* Py_BUILD_CORE */
83+
# endif /* _PyEXPORTS_CORE */
8484
# endif /* HAVE_DECLSPEC_DLL */
8585
#endif /* Py_ENABLE_SHARED */
8686

Include/pyabi.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,19 @@
7979
# endif
8080
#endif
8181

82+
// The internal C API must not be used with the limited C API: make sure
83+
// that Py_BUILD_CORE* macros are not defined in this case.
84+
// But, keep the "original" values, under different names, for "exports.h"
85+
#ifdef Py_BUILD_CORE
86+
# define _PyEXPORTS_CORE
87+
#endif
88+
#ifdef Py_BUILD_CORE_MODULE
89+
# define _PyEXPORTS_CORE_MODULE
90+
#endif
91+
#ifdef Py_LIMITED_API
92+
# undef Py_BUILD_CORE
93+
# undef Py_BUILD_CORE_BUILTIN
94+
# undef Py_BUILD_CORE_MODULE
95+
#endif
96+
8297
#endif // _Py_PYABI_H

Include/pyport.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,6 @@ extern "C" {
365365
# define Py_NO_INLINE
366366
#endif
367367

368-
#include "exports.h"
369-
370-
#ifdef Py_LIMITED_API
371-
// The internal C API must not be used with the limited C API: make sure
372-
// that Py_BUILD_CORE macro is not defined in this case. These 3 macros are
373-
// used by exports.h, so only undefine them afterwards.
374-
# undef Py_BUILD_CORE
375-
# undef Py_BUILD_CORE_BUILTIN
376-
# undef Py_BUILD_CORE_MODULE
377-
#endif
378-
379368
/* limits.h constants that may be missing */
380369

381370
#ifndef INT_MAX

0 commit comments

Comments
 (0)