From 50d0825256ddb76c5567e6cc8eb50e7d36908e21 Mon Sep 17 00:00:00 2001
From: Matus Valo <matusvalo@gmail.com>
Date: Mon, 17 Apr 2023 23:00:04 +0200
Subject: [PATCH] Mark function pointer ctypedefs as noexcept

---
 scipy/cluster/_hierarchy_distance_update.pxi | 2 +-
 scipy/optimize/cython_optimize/_zeros.pxd    | 2 +-
 scipy/stats/_qmc_cy.pyx                      | 2 +-
 scipy/stats/_unuran/unuran_wrapper.pyx.templ | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/scipy/cluster/_hierarchy_distance_update.pxi b/scipy/cluster/_hierarchy_distance_update.pxi
index 17dedb305..bc57a3fa1 100644
--- a/scipy/cluster/_hierarchy_distance_update.pxi
+++ b/scipy/cluster/_hierarchy_distance_update.pxi
@@ -24,7 +24,7 @@ d_xyi : double
 """
 ctypedef double (*linkage_distance_update)(double d_xi, double d_yi,
                                            double d_xy, int size_x,
-                                           int size_y, int size_i)
+                                           int size_y, int size_i) noexcept
 
 
 cdef double _single(double d_xi, double d_yi, double d_xy,
diff --git a/scipy/optimize/cython_optimize/_zeros.pxd b/scipy/optimize/cython_optimize/_zeros.pxd
index c6241d022..d3c9e98f0 100644
--- a/scipy/optimize/cython_optimize/_zeros.pxd
+++ b/scipy/optimize/cython_optimize/_zeros.pxd
@@ -4,7 +4,7 @@
 # should be made to this file** --- any API additions/changes should be
 # done in `cython_optimize.pxd` (see gh-11793).
 
-ctypedef double (*callback_type)(double, void*)
+ctypedef double (*callback_type)(double, void*) noexcept
 
 ctypedef struct zeros_parameters:
     callback_type function
diff --git a/scipy/stats/_qmc_cy.pyx b/scipy/stats/_qmc_cy.pyx
index f165cb0d1..a9e94354f 100644
--- a/scipy/stats/_qmc_cy.pyx
+++ b/scipy/stats/_qmc_cy.pyx
@@ -290,7 +290,7 @@ cdef double c_update_discrepancy(double[::1] x_new_view,
 
 
 ctypedef double (*func_type)(double[:, ::1], Py_ssize_t,
-                             Py_ssize_t) nogil
+                             Py_ssize_t) noexcept nogil
 
 
 cdef double threaded_loops(func_type loop_func,
diff --git a/scipy/stats/_unuran/unuran_wrapper.pyx.templ b/scipy/stats/_unuran/unuran_wrapper.pyx.templ
index 2279dfc34..9eb63fb1c 100644
--- a/scipy/stats/_unuran/unuran_wrapper.pyx.templ
+++ b/scipy/stats/_unuran/unuran_wrapper.pyx.templ
@@ -58,7 +58,7 @@ class UNURANError(RuntimeError):
     pass
 
 
-ctypedef double (*URNG_FUNCT)(void *) nogil
+ctypedef double (*URNG_FUNCT)(void *) noexcept nogil
 
 IF not NPY_OLD:
     cdef object get_numpy_rng(object seed = None):
-- 
2.23.0

