summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cython/Utility/ObjectHandling.c5
-rw-r--r--Tools/ci-run.sh10
2 files changed, 14 insertions, 1 deletions
diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c
index 8b572ca6f..02574e46e 100644
--- a/Cython/Utility/ObjectHandling.c
+++ b/Cython/Utility/ObjectHandling.c
@@ -2321,7 +2321,10 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
return __Pyx_PyFunction_FastCall(func, NULL, 0);
}
#endif
-#ifdef __Pyx_CyFunction_USED
+#if defined(__Pyx_CyFunction_USED) && defined(NDEBUG)
+ // TODO PyCFunction_GET_FLAGS has a type-check assert that breaks with a CyFunction
+ // in debug mode. There is likely to be a better way of avoiding tripping this
+ // check that doesn't involve disabling the optimized path.
if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
if (likely(PyCFunction_Check(func)))
diff --git a/Tools/ci-run.sh b/Tools/ci-run.sh
index c55f115d8..09e9ae318 100644
--- a/Tools/ci-run.sh
+++ b/Tools/ci-run.sh
@@ -109,6 +109,16 @@ export PATH="/usr/lib/ccache:$PATH"
# to override the previous ones, so '-O0 -O3' == '-O3'
# This is true for the latest msvc, gcc and clang
CFLAGS="-O0 -ggdb -Wall -Wextra"
+# Trying to cover debug assertions in the CI without adding
+# extra jobs. Therefore, odd-numbered minor versions of Python
+# running C++ jobs get NDEBUG undefined, and even-numbered
+# versions running C jobs get NDEBUG undefined.
+ODD_VERSION=$(python3 -c "import sys; print(sys.version_info[1]%2)")
+if [[ $BACKEND == *"cpp"* && $ODD_VERSION == "1" ]]; then
+ CFLAGS="$CFLAGS -UNDEBUG"
+elif [[ $ODD_VERSION == "0" ]]; then
+ CFLAGS="$CFLAGS -UNDEBUG"
+fi
if [[ $NO_CYTHON_COMPILE != "1" && $PYTHON_VERSION != "pypy"* ]]; then