From 9dd160ea0fb9583f685de25044b70e5124c9756e Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 19 Jun 2024 09:37:12 +0300 Subject: [PATCH 1/4] define these functions only in debug build --- Python/import.c | 3 ++- Python/pystate.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Python/import.c b/Python/import.c index 2c7a461ac786c8..47370136aef429 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1551,6 +1551,7 @@ get_core_module_dict(PyInterpreterState *interp, return NULL; } +#ifdef Py_DEBUG static inline int is_core_module(PyInterpreterState *interp, PyObject *name, PyObject *path) { @@ -1566,7 +1567,7 @@ is_core_module(PyInterpreterState *interp, PyObject *name, PyObject *path) } return 0; } - +#endif #ifndef NDEBUG static _Py_ext_module_kind diff --git a/Python/pystate.c b/Python/pystate.c index e1a95907b57d20..eb6dec8441f3a8 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -584,9 +584,9 @@ free_interpreter(PyInterpreterState *interp) PyMem_RawFree(interp); } } - +#ifdef Py_DEBUG static inline int check_interpreter_whence(long); - +#endif /* Get the interpreter state to a minimal consistent state. Further init happens in pylifecycle.c before it can be used. All fields not initialized here are expected to be zeroed out, @@ -1130,7 +1130,7 @@ _PyInterpreterState_IsReady(PyInterpreterState *interp) return interp->_ready; } - +#ifdef Py_DEBUG static inline int check_interpreter_whence(long whence) { @@ -1142,6 +1142,7 @@ check_interpreter_whence(long whence) } return 0; } +#endif long _PyInterpreterState_GetWhence(PyInterpreterState *interp) From 3cbb87078c8a983b9dd47670371db619ccb85304 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 19 Jun 2024 09:48:33 +0300 Subject: [PATCH 2/4] Use NDEBUG instead of Py_DEBUG --- Python/import.c | 2 +- Python/pystate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/import.c b/Python/import.c index 47370136aef429..92ec0f47354864 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1551,7 +1551,7 @@ get_core_module_dict(PyInterpreterState *interp, return NULL; } -#ifdef Py_DEBUG +#ifdef NDEBUG static inline int is_core_module(PyInterpreterState *interp, PyObject *name, PyObject *path) { diff --git a/Python/pystate.c b/Python/pystate.c index eb6dec8441f3a8..0fcc49f45bfadd 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -584,7 +584,7 @@ free_interpreter(PyInterpreterState *interp) PyMem_RawFree(interp); } } -#ifdef Py_DEBUG +#ifdef NDEBUG static inline int check_interpreter_whence(long); #endif /* Get the interpreter state to a minimal consistent state. @@ -1130,7 +1130,7 @@ _PyInterpreterState_IsReady(PyInterpreterState *interp) return interp->_ready; } -#ifdef Py_DEBUG +#ifdef NDEBUG static inline int check_interpreter_whence(long whence) { From 4f76c81ff58842716ac7423c9221e55b57c5f77e Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 19 Jun 2024 09:51:34 +0300 Subject: [PATCH 3/4] ...and ifndef instead of ifdef --- Python/import.c | 2 +- Python/pystate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/import.c b/Python/import.c index 92ec0f47354864..d5297a2caf3222 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1551,7 +1551,7 @@ get_core_module_dict(PyInterpreterState *interp, return NULL; } -#ifdef NDEBUG +#ifndef NDEBUG static inline int is_core_module(PyInterpreterState *interp, PyObject *name, PyObject *path) { diff --git a/Python/pystate.c b/Python/pystate.c index 0fcc49f45bfadd..8d31a4db200d74 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -584,7 +584,7 @@ free_interpreter(PyInterpreterState *interp) PyMem_RawFree(interp); } } -#ifdef NDEBUG +#ifndef NDEBUG static inline int check_interpreter_whence(long); #endif /* Get the interpreter state to a minimal consistent state. @@ -1130,7 +1130,7 @@ _PyInterpreterState_IsReady(PyInterpreterState *interp) return interp->_ready; } -#ifdef NDEBUG +#ifndef NDEBUG static inline int check_interpreter_whence(long whence) { From 4e3b9a561feb90fb1cf42f030e2edd477ed65e21 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 19 Jun 2024 10:22:28 +0300 Subject: [PATCH 4/4] Update Python/import.c Co-authored-by: Serhiy Storchaka --- Python/import.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Python/import.c b/Python/import.c index d5297a2caf3222..828d283df5c5a8 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1567,9 +1567,8 @@ is_core_module(PyInterpreterState *interp, PyObject *name, PyObject *path) } return 0; } -#endif -#ifndef NDEBUG + static _Py_ext_module_kind _get_extension_kind(PyModuleDef *def, bool check_size) {