Skip to content

Commit

Permalink
Avoid triggering type-check assert for cyfuncs [0.29.x] (#5031)
Browse files Browse the repository at this point in the history
* Avoid triggering type-check assert for cyfuncs
* Make some jobs run with debug assertions

Co-authored-by: Stefano Rivera <github@rivera.za.net>
  • Loading branch information
da-woods and stefanor committed Nov 26, 2022
1 parent d13a5c4 commit 8930130
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cython/Utility/ObjectHandling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
10 changes: 10 additions & 0 deletions Tools/ci-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8930130

Please sign in to comment.