bpo-35081: Internal headers require Py_BUILD_CORE (GH-10363) · python/cpython@130893d (original) (raw)

16 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ extern "C" {
9 9 *** Its definition may be changed or removed at any moment.
10 10 ***/
11 11
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"
14 +#endif
15 +
12 16 /*
13 17 * A two-level accumulator of unicode objects that avoids both the overhead
14 18 * of keeping a huge number of small separate objects, and the quadratic
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
4 4 extern "C" {
5 5 #endif
6 6
7 -#ifndef Py_BUILD_CORE
8 -# error "Py_BUILD_CORE must be defined to include this header"
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"
9 9 #endif
10 10
11 11 #include "dynamic_annotations.h"
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
4 4 extern "C" {
5 5 #endif
6 6
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"
9 +#endif
10 +
7 11 #include "pycore_atomic.h"
8 12 #include "pythread.h"
9 13
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1 1 #ifndef Py_INTERNAL_CONDVAR_H
2 2 #define Py_INTERNAL_CONDVAR_H
3 3
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"
6 +#endif
7 +
4 8 #ifndef _POSIX_THREADS
5 9 /* This means pthreads are not implemented in libc headers, hence the macro
6 10 not present in unistd.h. But they still can be implemented as an external
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
1 1 #ifndef Py_INTERNAL_CONTEXT_H
2 2 #define Py_INTERNAL_CONTEXT_H
3 3
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"
6 +#endif
4 7
5 8 #include "pycore_hamt.h"
6 9
7 -
8 10 struct _pycontextobject {
9 11 PyObject_HEAD
10 12 PyContext *ctx_prev;
@@ -37,5 +39,4 @@ struct _pycontexttokenobject {
37 39 int _PyContext_Init(void);
38 40 void _PyContext_Fini(void);
39 41
40 -
41 42 #endif /* !Py_INTERNAL_CONTEXT_H */
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1 1 #ifndef Py_INTERNAL_PYGETOPT_H
2 2 #define Py_INTERNAL_PYGETOPT_H
3 3
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"
6 +#endif
7 +
4 8 extern int _PyOS_opterr;
5 9 extern int _PyOS_optind;
6 10 extern wchar_t *_PyOS_optarg;
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
4 4 extern "C" {
5 5 #endif
6 6
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"
9 +#endif
10 +
7 11 #include "pycore_condvar.h"
8 12 #include "pycore_atomic.h"
9 13
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
1 1 #ifndef Py_INTERNAL_HAMT_H
2 2 #define Py_INTERNAL_HAMT_H
3 3
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"
6 +#endif
4 7
5 8 #define _Py_HAMT_MAX_TREE_DEPTH 7
6 9
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1 1 #ifndef Py_INTERNAL_HASH_H
2 2 #define Py_INTERNAL_HASH_H
3 3
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"
6 +#endif
7 +
4 8 uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t);
5 9
6 10 #endif
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
4 4 extern "C" {
5 5 #endif
6 6
7 -#ifndef Py_BUILD_CORE
8 -# error "Py_BUILD_CORE must be defined to include this header"
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"
9 9 #endif
10 10
11 11 PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv);
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
4 4 extern "C" {
5 5 #endif
6 6
7 -#ifndef Py_BUILD_CORE
8 -# error "Py_BUILD_CORE must be defined to include this header"
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"
9 9 #endif
10 10
11 11 #include "objimpl.h"
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
4 4 extern "C" {
5 5 #endif
6 6
7 -#ifndef Py_BUILD_CORE
8 -# error "Py_BUILD_CORE must be defined to include this header"
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"
9 9 #endif
10 10
11 11 PyAPI_FUNC(void) _Py_wstrlist_clear(
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
4 4 extern "C" {
5 5 #endif
6 6
7 -#ifndef Py_BUILD_CORE
8 -# error "Py_BUILD_CORE must be defined to include this header"
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"
9 9 #endif
10 10
11 11 #include "pystate.h"
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
4 4 extern "C" {
5 5 #endif
6 6
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"
9 +#endif
10 +
7 11 #include "object.h"
8 12
9 13 struct _warnings_runtime_state {
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@ _symtable symtablemodule.c
180 180 #_bisect _bisectmodule.c # Bisection algorithms
181 181 #_heapq _heapqmodule.c # Heap queue algorithm
182 182 #_asyncio _asynciomodule.c # Fast asyncio Future
183 +#_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c # _json speedups
183 184
184 185 #unicodedata unicodedata.c # static Unicode character database
185 186
Original file line number Diff line number Diff line change
@@ -678,7 +678,9 @@ def detect_modules(self):
678 678 # atexit
679 679 exts.append( Extension("atexit", ["atexitmodule.c"]) )
680 680 # _json speedups
681 -exts.append( Extension("_json", ["_json.c"]) )
681 +exts.append( Extension("_json", ["_json.c"],
682 +# pycore_accu.h requires Py_BUILD_CORE_BUILTIN
683 +extra_compile_args=['-DPy_BUILD_CORE_BUILTIN']) )
682 684 # Python C API test module
683 685 exts.append( Extension('_testcapi', ['_testcapimodule.c'],
684 686 depends=['testcapi_long.h']) )