Skip to content

Commit 5c75f37

Browse files
authored
bpo-36635: Change pyport.h for Py_BUILD_CORE_MODULE define (GH-12853)
Change PyAPI_FUNC(type), PyAPI_DATA(type) and PyMODINIT_FUNC macros of pyport.h when Py_BUILD_CORE_MODULE is defined. The Py_BUILD_CORE_MODULE define must be now be used to build a C extension as a dynamic library accessing Python internals: export the PyInit_xxx() function in DLL exports on Windows. Changes: * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE now imply Py_BUILD_CORE directy in pyport.h. * ceval.c compilation now fails with an error if Py_BUILD_CORE is not defined, just to ensure that Python is build with the correct defines. * setup.py now compiles _pickle.c with Py_BUILD_CORE_MODULE define. * setup.py compiles _json.c with Py_BUILD_CORE_MODULE define, rather than Py_BUILD_CORE_BUILTIN define * PCbuild/pythoncore.vcxproj: Add Py_BUILD_CORE_BUILTIN define.
1 parent 3092d6b commit 5c75f37

26 files changed

+97
-56
lines changed

Include/internal/pycore_accu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ extern "C" {
99
*** Its definition may be changed or removed at any moment.
1010
***/
1111

12-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
13-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
12+
#ifndef Py_BUILD_CORE
13+
# error "this header requires Py_BUILD_CORE define"
1414
#endif
1515

1616
/*

Include/internal/pycore_atomic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern "C" {
55
#endif
66

7-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
8-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

1111
#include "dynamic_annotations.h"

Include/internal/pycore_ceval.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern "C" {
55
#endif
66

7-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
8-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

1111
#include "pycore_atomic.h"

Include/internal/pycore_condvar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef Py_INTERNAL_CONDVAR_H
22
#define Py_INTERNAL_CONDVAR_H
33

4-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
5-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
4+
#ifndef Py_BUILD_CORE
5+
# error "this header requires Py_BUILD_CORE define"
66
#endif
77

88
#ifndef _POSIX_THREADS

Include/internal/pycore_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef Py_INTERNAL_CONTEXT_H
22
#define Py_INTERNAL_CONTEXT_H
33

4-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
5-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
4+
#ifndef Py_BUILD_CORE
5+
# error "this header requires Py_BUILD_CORE define"
66
#endif
77

88
#include "pycore_hamt.h"

Include/internal/pycore_coreconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern "C" {
55
#endif
66

7-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
8-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

1111

Include/internal/pycore_getopt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef Py_INTERNAL_PYGETOPT_H
22
#define Py_INTERNAL_PYGETOPT_H
33

4-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
5-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
4+
#ifndef Py_BUILD_CORE
5+
# error "this header requires Py_BUILD_CORE define"
66
#endif
77

88
extern int _PyOS_opterr;

Include/internal/pycore_gil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern "C" {
55
#endif
66

7-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
8-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

1111
#include "pycore_condvar.h"

Include/internal/pycore_hamt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef Py_INTERNAL_HAMT_H
22
#define Py_INTERNAL_HAMT_H
33

4-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
5-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
4+
#ifndef Py_BUILD_CORE
5+
# error "this header requires Py_BUILD_CORE define"
66
#endif
77

88
#define _Py_HAMT_MAX_TREE_DEPTH 7

Include/internal/pycore_object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern "C" {
55
#endif
66

7-
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
8-
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

1111
#include "pycore_pystate.h" /* _PyRuntime */

0 commit comments

Comments
 (0)