From 51be18e36254c7fde29f7407d00f61522f3dc60c Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 22 Oct 2021 13:56:55 +0200 Subject: [PATCH 1/5] bpo-43974: Move Py_BUILD_CORE_MODULE into module code ``setup.py`` no longer defines ``Py_BUILD_CORE_MODULE``. Instead every module defines the macro before ``#include "Python.h"`` unless ``Py_BUILD_CORE_BUILTIN`` is already defined. ``Py_BUILD_CORE_BUILTIN`` is defined for every module that is built by ``Modules/Setup``. Signed-off-by: Christian Heimes --- .../2021-10-22-14-00-44.bpo-43974.HHZtbx.rst | 2 + Modules/_asynciomodule.c | 4 ++ Modules/_blake2/blake2b_impl.c | 4 ++ Modules/_blake2/blake2module.c | 4 ++ Modules/_blake2/blake2s_impl.c | 4 ++ Modules/_ctypes/_ctypes.c | 3 + Modules/_ctypes/callbacks.c | 4 ++ Modules/_ctypes/cfield.c | 4 ++ Modules/_ctypes/stgdict.c | 4 ++ Modules/_cursesmodule.c | 4 ++ Modules/_datetimemodule.c | 4 ++ Modules/_decimal/_decimal.c | 3 + Modules/_hashopenssl.c | 4 ++ Modules/_heapqmodule.c | 4 ++ Modules/_json.c | 4 +- Modules/_lsprof.c | 4 ++ Modules/_math.c | 4 ++ Modules/_pickle.c | 4 +- Modules/_posixsubprocess.c | 4 ++ Modules/_queuemodule.c | 4 ++ Modules/_randommodule.c | 4 ++ Modules/_sha3/sha3module.c | 4 ++ Modules/_struct.c | 4 ++ Modules/_testinternalcapi.c | 4 +- Modules/_testmultiphase.c | 3 + Modules/_xxsubinterpretersmodule.c | 3 + Modules/_zoneinfo.c | 4 ++ Modules/arraymodule.c | 4 ++ Modules/binascii.c | 4 ++ Modules/cmathmodule.c | 4 ++ Modules/mathmodule.c | 4 ++ Modules/md5module.c | 3 + Modules/sha1module.c | 3 + Modules/sha256module.c | 3 + Modules/sha512module.c | 3 + Modules/unicodedata.c | 4 ++ setup.py | 68 ++++++------------- 37 files changed, 148 insertions(+), 54 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2021-10-22-14-00-44.bpo-43974.HHZtbx.rst diff --git a/Misc/NEWS.d/next/Build/2021-10-22-14-00-44.bpo-43974.HHZtbx.rst b/Misc/NEWS.d/next/Build/2021-10-22-14-00-44.bpo-43974.HHZtbx.rst new file mode 100644 index 00000000000000..728a095dc03af2 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-10-22-14-00-44.bpo-43974.HHZtbx.rst @@ -0,0 +1,2 @@ +``setup.py`` no longer defines ``Py_BUILD_CORE_MODULE``. Instead every +module, that uses the internal API, defines the macro. diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index adc5ff9f796cca..963390ab336e32 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_pyerrors.h" // _PyErr_ClearExcState() #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index b16324e8f7aeb8..99bda8ba248b3a 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -13,6 +13,10 @@ * The blake2s_impl.c is autogenerated from blake2b_impl.c. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_strhex.h" // _Py_strhex() diff --git a/Modules/_blake2/blake2module.c b/Modules/_blake2/blake2module.c index 631de2cc0abc74..f40da28415194d 100644 --- a/Modules/_blake2/blake2module.c +++ b/Modules/_blake2/blake2module.c @@ -8,6 +8,10 @@ * any warranty. http://creativecommons.org/publicdomain/zero/1.0/ */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "impl/blake2.h" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 6b31a363ea27b9..5cd0acf2743971 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -13,6 +13,10 @@ * The blake2s_impl.c is autogenerated from blake2s_impl.c. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_strhex.h" // _Py_strhex() diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f8940fdbed2424..992c0d89db3de5 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -98,6 +98,9 @@ bytes(cdata) * PyCField_Type * */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index c24f04ce3a0f8e..1defcbb71eccd3 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" // windows.h must be included before pycore internal headers #ifdef MS_WIN32 diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 2cfd657028aca0..8eb99e2a762cfe 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" // windows.h must be included before pycore internal headers #ifdef MS_WIN32 diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 43669d7152a7e9..6295c65fcb62fd 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" // windows.h must be included before pycore internal headers #ifdef MS_WIN32 diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 511073f2ac1379..da7ab17fc21d6b 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -100,6 +100,10 @@ static const char PyCursesVersion[] = "2.2"; /* Includes */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index e54a01b44c5bad..46598e4df22c77 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -7,6 +7,10 @@ * the capsule are defined below */ #define _PY_DATETIME_IMPL +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_long.h" // _PyLong_GetOne() #include "pycore_object.h" // _PyObject_Init() diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 237edd5191fd94..fe00aaaafcc9e6 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -25,6 +25,9 @@ * SUCH DAMAGE. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index b4ba60baaac93d..bcb2aa6da3114c 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -18,6 +18,10 @@ #endif #define OPENSSL_NO_DEPRECATED 1 +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 20468c28f24234..c4ac8162abeb7f 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -6,6 +6,10 @@ annotated by François Pinard, and converted to C by Raymond Hettinger. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_list.h" // _PyList_ITEMS() diff --git a/Modules/_json.c b/Modules/_json.c index 6f68c1f7f9b715..93b1f1532e39e3 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -4,8 +4,8 @@ * and as an extension module (Py_BUILD_CORE_MODULE define) on other * platforms. */ -#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) -# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 2e27afcea1b799..2ed18b2b33dc90 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Modules/_math.c b/Modules/_math.c index 68e3a2346925de..e72f1c3f0b19e9 100644 --- a/Modules/_math.c +++ b/Modules/_math.c @@ -1,6 +1,10 @@ /* Definitions of some C99 math library functions, for those platforms that don't implement these functions already. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include #include "_math.h" diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 53ab57111967ce..035727b626b890 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4,8 +4,8 @@ * and as an extension module (Py_BUILD_CORE_MODULE define) on other * platforms. */ -#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) -# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 63207de8b91371..67e865f93a3070 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -1,4 +1,8 @@ /* Authors: Gregory P. Smith & Jeffrey Yasskin */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_fileutils.h" #if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE) diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index eb61349b76581d..77aa3641bf77a6 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_moduleobject.h" // _PyModule_GetState() #include "structmember.h" // PyMemberDef diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 65d41f4e8e80c7..f169132d0b9a12 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -66,6 +66,10 @@ /* ---------------------------------------------------------------*/ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_moduleobject.h" // _PyModule_GetState() #ifdef HAVE_PROCESS_H diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index a033c4e4525456..955eededc0a3d1 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -15,6 +15,10 @@ * */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_strhex.h" // _Py_strhex() #include "../hashlib.h" diff --git a/Modules/_struct.c b/Modules/_struct.c index a8003a90b2682c..161f16c9d50da0 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -3,6 +3,10 @@ /* New version supporting byte order, alignment and size options, character strings, and unsigned numbers */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 3ba939651a4173..3bc63a0d337ed9 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -2,8 +2,8 @@ * C Extension module to test Python internal C APIs (Include/internal). */ -#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) -# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 #endif /* Always enable assertions */ diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 2d25e16bd4d390..810ddb2c1bea7d 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -1,6 +1,9 @@ /* Testing module for multi-phase initialization of extension modules (PEP 489) */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "pycore_namespace.h" // _PyNamespace_New() diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index b5c0a632191146..8fb03db7f1991f 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -1,6 +1,9 @@ /* interpreters module */ /* low-level access to interpreter primitives */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "frameobject.h" diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 04fa09422b2134..2d407b103d324b 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -1,3 +1,7 @@ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_long.h" // _PyLong_GetOne() #include "structmember.h" diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 5e57fe116059de..dd9d939d0efe04 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -3,6 +3,10 @@ /* An array is a uniform list -- all items have the same type. The item type is restricted to simple C types like int or float */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" #include "pycore_floatobject.h" // _PyFloat_Unpack4() diff --git a/Modules/binascii.c b/Modules/binascii.c index 7037d34dbe2dd5..8e854eceb77d4c 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -53,6 +53,10 @@ ** Brandon Long, September 2001. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 0f22049a170848..3dda93523f7de9 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -2,6 +2,10 @@ /* much code borrowed from mathmodule.c */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_dtoa.h" #include "_math.h" diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 4fac0cc29e4e98..87f921461d1f5d 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -52,6 +52,10 @@ raised for division by zero and mod by zero. returned. */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #include "Python.h" #include "pycore_bitutils.h" // _Py_bit_length() #include "pycore_call.h" // _PyObject_CallNoArgs() diff --git a/Modules/md5module.c b/Modules/md5module.c index 4d03f6b844b332..6d783f61a5f6eb 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -15,6 +15,9 @@ */ /* MD5 objects */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "hashlib.h" diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 153bc12a8bd743..db3adb0f9fde91 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -15,6 +15,9 @@ */ /* SHA1 objects */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "hashlib.h" diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 5858071db4e133..ccf33444b0b655 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -15,6 +15,9 @@ */ /* SHA objects */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "pycore_bitutils.h" // _Py_bswap32() diff --git a/Modules/sha512module.c b/Modules/sha512module.c index e50b69be4617d9..18f57e025666bc 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -15,6 +15,9 @@ */ /* SHA objects */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "pycore_bitutils.h" // _Py_bswap64() diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index e863e53bfa9f17..ccaec24584b1d1 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -12,6 +12,10 @@ ------------------------------------------------------------------------ */ +#ifndef Py_BUILD_CORE_BUILTIN + #define Py_BUILD_CORE_MODULE 1 +#endif + #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/setup.py b/setup.py index 5428cbde1cc9b0..03dce63984ef30 100644 --- a/setup.py +++ b/setup.py @@ -899,8 +899,7 @@ def detect_simple_extensions(self): # # array objects - self.add(Extension('array', ['arraymodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('array', ['arraymodule.c'])) # Context Variables self.add(Extension('_contextvars', ['_contextvarsmodule.c'])) @@ -909,14 +908,12 @@ def detect_simple_extensions(self): # math library functions, e.g. sin() self.add(Extension('math', ['mathmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], extra_objects=[shared_math], depends=['_math.h', shared_math], libraries=['m'])) # complex math library functions self.add(Extension('cmath', ['cmathmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], extra_objects=[shared_math], depends=['_math.h', shared_math], libraries=['m'])) @@ -933,44 +930,33 @@ def detect_simple_extensions(self): # libm is needed by delta_new() that uses round() and by accum() that # uses modf(). self.add(Extension('_datetime', ['_datetimemodule.c'], - libraries=['m'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + libraries=['m'])) # zoneinfo module - self.add(Extension('_zoneinfo', ['_zoneinfo.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_zoneinfo', ['_zoneinfo.c'])) # random number generator implemented in C - self.add(Extension("_random", ["_randommodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_random", ["_randommodule.c"])) # bisect self.add(Extension("_bisect", ["_bisectmodule.c"])) # heapq - self.add(Extension("_heapq", ["_heapqmodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_heapq", ["_heapqmodule.c"])) # C-optimized pickle replacement - self.add(Extension("_pickle", ["_pickle.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_pickle", ["_pickle.c"])) # _json speedups - self.add(Extension("_json", ["_json.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_json", ["_json.c"])) # profiler (_lsprof is for cProfile.py) - self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'])) # static Unicode character database self.add(Extension('unicodedata', ['unicodedata.c'], - depends=['unicodedata_db.h', 'unicodename_db.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + depends=['unicodedata_db.h', 'unicodename_db.h'])) # _opcode module self.add(Extension('_opcode', ['_opcode.c'])) # asyncio speedups - self.add(Extension("_asyncio", ["_asynciomodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_asyncio", ["_asynciomodule.c"])) # _abc speedups - self.add(Extension("_abc", ["_abc.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_abc", ["_abc.c"])) # _queue module - self.add(Extension("_queue", ["_queuemodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_queue", ["_queuemodule.c"])) # _statistics module self.add(Extension("_statistics", ["_statisticsmodule.c"])) # _typing module @@ -1012,8 +998,7 @@ def detect_simple_extensions(self): self.add(Extension('syslog', ['syslogmodule.c'])) # Python interface to subinterpreter C-API. - self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) # # Here ends the simple stuff. From here on, modules need certain @@ -1036,8 +1021,7 @@ def detect_simple_extensions(self): self.add(Extension('_csv', ['_csv.c'])) # POSIX subprocess module helper. - self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'])) def detect_test_extensions(self): # Python C API test module @@ -1045,8 +1029,7 @@ def detect_test_extensions(self): depends=['testcapi_long.h'])) # Python Internal C API test module - self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'])) # Python PEP-3118 (buffer protocol) test module self.add(Extension('_testbuffer', ['_testbuffer.c'])) @@ -1055,8 +1038,7 @@ def detect_test_extensions(self): self.add(Extension('_testimportmultiple', ['_testimportmultiple.c'])) # Test multi-phase extension module init (PEP 489) - self.add(Extension('_testmultiphase', ['_testmultiphase.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_testmultiphase', ['_testmultiphase.c'])) # Fuzz tests. self.add(Extension('_xxtestfuzz', @@ -1187,7 +1169,6 @@ def detect_readline_curses(self): if curses_library.startswith('ncurses'): curses_libs = [curses_library] self.add(Extension('_curses', ['_cursesmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], include_dirs=curses_includes, define_macros=curses_defines, libraries=curses_libs)) @@ -1202,7 +1183,6 @@ def detect_readline_curses(self): curses_libs = ['curses'] self.add(Extension('_curses', ['_cursesmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], define_macros=curses_defines, libraries=curses_libs)) else: @@ -1722,7 +1702,7 @@ def detect_compress_exts(self): # Helper module for various ascii-encoders. Uses zlib for an optimized # crc32 if we have it. Otherwise binascii uses its own. - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] if have_zlib: extra_compile_args.append('-DUSE_ZLIB_CRC32') libraries = ['z'] @@ -2230,7 +2210,7 @@ def detect_ctypes(self): self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS") include_dirs = [] - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] extra_link_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', @@ -2324,7 +2304,7 @@ def detect_ctypes(self): def detect_decimal(self): # Stefan Krah's _decimal module - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] undef_macros = [] if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): include_dirs = [] @@ -2482,7 +2462,6 @@ def split_var(name, sep): library_dirs=openssl_libdirs, libraries=openssl_libs, runtime_library_dirs=runtime_library_dirs, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], ) # This static linking is NOT OFFICIALLY SUPPORTED. @@ -2545,28 +2524,24 @@ def detect_hash_builtins(self): self.add(Extension( '_sha256', ['sha256module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha512" in configured: self.add(Extension( '_sha512', ['sha512module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "md5" in configured: self.add(Extension( '_md5', ['md5module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha1" in configured: self.add(Extension( '_sha1', ['sha1module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "blake2" in configured: @@ -2582,7 +2557,6 @@ def detect_hash_builtins(self): '_blake2/blake2s_impl.c' ], depends=blake2_deps, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha3" in configured: @@ -2594,7 +2568,6 @@ def detect_hash_builtins(self): '_sha3', ['_sha3/sha3module.c'], depends=sha3_deps, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) def detect_nis(self): @@ -2750,8 +2723,7 @@ class DummyProcess: 'install_lib': PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('_struct', ['_struct.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # If you change the scripts installed here, you also need to # check the PyBuildScripts command above, and change the links From d47314ac4a463785bef299ed9335914eedfa013b Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 22 Oct 2021 14:02:57 +0200 Subject: [PATCH 2/5] PCbuild: Dont' define Py_BUILD_CORE_MODULE --- PCbuild/pyproject.props | 1 - 1 file changed, 1 deletion(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index d492b71dfbaa3d..bbcabb5cdb4058 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -25,7 +25,6 @@ <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG; <_PlatformPreprocessorDefinition>_WIN32; <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;_M_X64; - <_PydPreprocessorDefinition Condition="$(TargetExt) == '.pyd'">Py_BUILD_CORE_MODULE; <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)"; From 80561b5f750d2b5d22e483aca3c244c156fbd942 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 22 Oct 2021 14:03:05 +0200 Subject: [PATCH 3/5] Simplify Modules/Setup Makefile and makesetup already define ``Py_BUILD_CORE_BUILTIN`` and include ``Modules/internal`` for us. --- Modules/Setup | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Modules/Setup b/Modules/Setup index a4440dfb6fc9dd..a5b1a7b9c14afa 100644 --- a/Modules/Setup +++ b/Modules/Setup @@ -99,26 +99,26 @@ PYTHONPATH=$(COREPYTHONPATH) # cannot be built as shared! _collections _collectionsmodule.c -_abc -DPy_BUILD_CORE_BUILTIN _abc.c +_abc _abc.c _codecs _codecsmodule.c -_functools -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _functoolsmodule.c -_io -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c -_locale -DPy_BUILD_CORE_BUILTIN _localemodule.c # -lintl -_operator -DPy_BUILD_CORE_BUILTIN _operator.c -_signal -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal signalmodule.c -_sre -DPy_BUILD_CORE_BUILTIN _sre.c +_functools _functoolsmodule.c +_io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c +_locale _localemodule.c # -lintl +_operator _operator.c +_signal signalmodule.c +_sre _sre.c _stat _stat.c _symtable symtablemodule.c # setup.py can't track the .h file that _symtable depends on. -_thread -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _threadmodule.c +_thread _threadmodule.c _tracemalloc _tracemalloc.c # See bpo-35053 as to why this is built in. _weakref _weakref.c atexit atexitmodule.c errno errnomodule.c faulthandler faulthandler.c itertools itertoolsmodule.c -posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c +posix posixmodule.c pwd pwdmodule.c -time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c +time timemodule.c # --- @@ -139,7 +139,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c #_asyncio _asynciomodule.c #_bisect _bisectmodule.c -#_blake2 -DPy_BUILD_CORE_BUILTIN _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c +#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c #_codecs_cn cjkcodecs/_codecs_cn.c #_codecs_hk cjkcodecs/_codecs_hk.c #_codecs_iso2022 cjkcodecs/_codecs_iso2022.c @@ -150,31 +150,31 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c #_csv _csv.c #_datetime _datetimemodule.c #_elementtree -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat _elementtree.c -#_heapq -DPy_BUILD_CORE_MODULE _heapqmodule.c -#_json -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _json.c +#_heapq _heapqmodule.c +#_json _json.c #_lsprof _lsprof.c rotatingtree.c -#_md5 -DPy_BUILD_CORE_BUILTIN md5module.c +#_md5 md5module.c #_multibytecodec cjkcodecs/multibytecodec.c #_opcode _opcode.c -#_pickle -DPy_BUILD_CORE_MODULE _pickle.c -#_posixsubprocess -DPy_BUILD_CORE_BUILTIN _posixsubprocess.c -#_queue -DPy_BUILD_CORE_MODULE _queuemodule.c -#_random -DPy_BUILD_CORE_MODULE _randommodule.c -#_sha1 -DPy_BUILD_CORE_BUILTIN sha1module.c -#_sha256 -DPy_BUILD_CORE_BUILTIN sha256module.c -#_sha512 -DPy_BUILD_CORE_BUILTIN sha512module.c -#_sha3 -DPy_BUILD_CORE_BUILTIN _sha3/sha3module.c +#_pickle _pickle.c +#_posixsubprocess _posixsubprocess.c +#_queue _queuemodule.c +#_random _randommodule.c +#_sha1 sha1module.c +#_sha256 sha256module.c +#_sha512 sha512module.c +#_sha3 _sha3/sha3module.c #_statistics _statisticsmodule.c -#_struct -DPy_BUILD_CORE_MODULE _struct.c +#_struct _struct.c #_typing _typingmodule.c -#_zoneinfo -DPy_BUILD_CORE_MODULE _zoneinfo.c -#array -DPy_BUILD_CORE_MODULE arraymodule.c +#_zoneinfo _zoneinfo.c +#array arraymodule.c #audioop audioop.c -#binascii -DPy_BUILD_CORE_MODULE binascii.c -#cmath -DPy_BUILD_CORE_MODULE cmathmodule.c _math.c # -lm -#math -DPy_BUILD_CORE_MODULE mathmodule.c _math.c # -lm +#binascii binascii.c +#cmath cmathmodule.c _math.c # -lm +#math mathmodule.c _math.c # -lm #pyexpat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -#unicodedata -DPy_BUILD_CORE_BUILTIN unicodedata.c +#unicodedata unicodedata.c # Modules with some UNIX dependencies -- on by default: # (If you have a really backward UNIX, select and socket may not be @@ -286,7 +286,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c # provided by the ncurses library. e.g. on Linux, link with -lncurses # instead of -lcurses). -#_curses -DPy_BUILD_CORE_MODULE -lcurses -ltermcap _cursesmodule.c +#_curses -lcurses -ltermcap _cursesmodule.c # Wrapper for the panel library that's part of ncurses and SYSV curses. #_curses_panel -lpanel -lncurses _curses_panel.c @@ -305,7 +305,7 @@ xxsubtype xxsubtype.c # Required for the test suite to pass! #_testbuffer _testbuffer.c #_testcapi _testcapimodule.c # CANNOT be statically compiled! #_testimportmultiple _testimportmultiple.c -#_testinternalcapi -DPy_BUILD_CORE_MODULE -I$(srcdir)/Include/internal _testinternalcapi.c +#_testinternalcapi _testinternalcapi.c #_testmultiphase _testmultiphase.c From 27831617b4d6e8e525fc753a71fbf567eb3f05e3 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 22 Oct 2021 14:10:09 +0200 Subject: [PATCH 4/5] Victor prefers a different style --- Modules/_asynciomodule.c | 2 +- Modules/_blake2/blake2b_impl.c | 2 +- Modules/_blake2/blake2module.c | 2 +- Modules/_blake2/blake2s_impl.c | 2 +- Modules/_ctypes/_ctypes.c | 2 +- Modules/_ctypes/callbacks.c | 2 +- Modules/_ctypes/cfield.c | 2 +- Modules/_ctypes/stgdict.c | 2 +- Modules/_cursesmodule.c | 2 +- Modules/_datetimemodule.c | 2 +- Modules/_decimal/_decimal.c | 2 +- Modules/_hashopenssl.c | 2 +- Modules/_heapqmodule.c | 2 +- Modules/_json.c | 2 +- Modules/_lsprof.c | 2 +- Modules/_math.c | 2 +- Modules/_pickle.c | 2 +- Modules/_posixsubprocess.c | 2 +- Modules/_queuemodule.c | 2 +- Modules/_randommodule.c | 2 +- Modules/_sha3/sha3module.c | 2 +- Modules/_struct.c | 2 +- Modules/_testinternalcapi.c | 2 +- Modules/_testmultiphase.c | 2 +- Modules/_xxsubinterpretersmodule.c | 2 +- Modules/_zoneinfo.c | 2 +- Modules/arraymodule.c | 2 +- Modules/binascii.c | 2 +- Modules/cmathmodule.c | 2 +- Modules/mathmodule.c | 2 +- Modules/md5module.c | 2 +- Modules/sha1module.c | 2 +- Modules/sha256module.c | 2 +- Modules/sha512module.c | 2 +- Modules/unicodedata.c | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 963390ab336e32..8386a50d55826d 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index 99bda8ba248b3a..e1421dd8ff8b82 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -14,7 +14,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_blake2/blake2module.c b/Modules/_blake2/blake2module.c index f40da28415194d..3b6bba277a3139 100644 --- a/Modules/_blake2/blake2module.c +++ b/Modules/_blake2/blake2module.c @@ -9,7 +9,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 5cd0acf2743971..763c0178e6bcd5 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -14,7 +14,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 992c0d89db3de5..96078c7726d597 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -99,7 +99,7 @@ bytes(cdata) * */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 1defcbb71eccd3..0f7789a973e8f2 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 8eb99e2a762cfe..515b2801820986 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 6295c65fcb62fd..6c1917b18d4509 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index da7ab17fc21d6b..3770a032e977dc 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -101,7 +101,7 @@ static const char PyCursesVersion[] = "2.2"; /* Includes */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 46598e4df22c77..67441eba28f7f6 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -8,7 +8,7 @@ #define _PY_DATETIME_IMPL #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index fe00aaaafcc9e6..7fc7315603e7ad 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -26,7 +26,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index bcb2aa6da3114c..12491917832b69 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -19,7 +19,7 @@ #define OPENSSL_NO_DEPRECATED 1 #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index c4ac8162abeb7f..3dbaaa0a0da1d6 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -7,7 +7,7 @@ annotated by François Pinard, and converted to C by Raymond Hettinger. */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_json.c b/Modules/_json.c index 93b1f1532e39e3..1c9c50665d466c 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -5,7 +5,7 @@ * platforms. */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 2ed18b2b33dc90..ff499aacbab374 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_math.c b/Modules/_math.c index e72f1c3f0b19e9..c1936a1088a243 100644 --- a/Modules/_math.c +++ b/Modules/_math.c @@ -2,7 +2,7 @@ that don't implement these functions already. */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 035727b626b890..0d9e57aa90d22f 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -5,7 +5,7 @@ * platforms. */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 67e865f93a3070..de599f8c970e38 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -1,6 +1,6 @@ /* Authors: Gregory P. Smith & Jeffrey Yasskin */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index 77aa3641bf77a6..413387fecc4cd5 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index f169132d0b9a12..5243d5a05e2900 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -67,7 +67,7 @@ /* ---------------------------------------------------------------*/ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index 955eededc0a3d1..bfa96616df0c99 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -16,7 +16,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_struct.c b/Modules/_struct.c index 161f16c9d50da0..210dbdc752f4c1 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -4,7 +4,7 @@ character strings, and unsigned numbers */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 3bc63a0d337ed9..1ca06069e11199 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -3,7 +3,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif /* Always enable assertions */ diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 810ddb2c1bea7d..ee69c42336170d 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -2,7 +2,7 @@ /* Testing module for multi-phase initialization of extension modules (PEP 489) */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index 8fb03db7f1991f..3f683768fcc28d 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -2,7 +2,7 @@ /* interpreters module */ /* low-level access to interpreter primitives */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 2d407b103d324b..cac347071f91db 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -1,5 +1,5 @@ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index dd9d939d0efe04..030ede57351e92 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -4,7 +4,7 @@ The item type is restricted to simple C types like int or float */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/binascii.c b/Modules/binascii.c index 8e854eceb77d4c..fec0d82a39cdd7 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -54,7 +54,7 @@ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 3dda93523f7de9..0e0489c5fe2d73 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -3,7 +3,7 @@ /* much code borrowed from mathmodule.c */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 87f921461d1f5d..6c12a4e70ddf20 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -53,7 +53,7 @@ raised for division by zero and mod by zero. */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/md5module.c b/Modules/md5module.c index 6d783f61a5f6eb..48b11e0779f875 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -16,7 +16,7 @@ /* MD5 objects */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/sha1module.c b/Modules/sha1module.c index db3adb0f9fde91..9153557fbde740 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -16,7 +16,7 @@ /* SHA1 objects */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/sha256module.c b/Modules/sha256module.c index ccf33444b0b655..17ee86683b7a89 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -16,7 +16,7 @@ /* SHA objects */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 18f57e025666bc..bf4408b455f2c4 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -16,7 +16,7 @@ /* SHA objects */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index ccaec24584b1d1..bdbddcf10b778f 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -13,7 +13,7 @@ ------------------------------------------------------------------------ */ #ifndef Py_BUILD_CORE_BUILTIN - #define Py_BUILD_CORE_MODULE 1 +# define Py_BUILD_CORE_MODULE 1 #endif #define PY_SSIZE_T_CLEAN From 2b5f23a63defd7c22f39fa6518f509fab526c635 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 22 Oct 2021 14:25:02 +0200 Subject: [PATCH 5/5] _abc also requires Py_BUILD_CORE --- Modules/_abc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_abc.c b/Modules/_abc.c index 8aa68359039e7d..b7465c379dddf4 100644 --- a/Modules/_abc.c +++ b/Modules/_abc.c @@ -1,4 +1,7 @@ /* ABCMeta implementation */ +#ifndef Py_BUILD_CORE_BUILTIN +# define Py_BUILD_CORE_MODULE 1 +#endif #include "Python.h" #include "pycore_moduleobject.h" // _PyModule_GetState()