Open tornaria opened 2 weeks ago
First thoughts:
cpdef
function is equivalent to a cdef
function + a def
wrapper. I think the noexcept
(or other except
clauses) apply only to the cdef
function since a def
function must have the standard python semantics (iirc a python function always return a python object as a pointer with null meaning check for exceptions).cdef
or cpdef
function that returns a python object should not be noexcept as cython will ignore the noexcept (with a warning in the case of cdef
functions, but maybe no warning for cpdef
functions: should investigate and if so file an issue upstream)cpdef
functions that return C types are in principle allowed to use noexcept
(unless they call raise
). In this case the def
wrapper will convert the C type into a python object iiuc.int
, long
, unsigned long
, bint
, size_t
, double
.This leaves us with 28 cases to check:
$ git grep cpdef.*noexcept | grep -E -v "\<cpdef +(inline +)?(int|(unsigned )?long|bint|size_t|double) "
src/sage/graphs/bliss.pyx:cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True, certificate=False) noexcept:
src/sage/graphs/bliss.pyx:cpdef automorphism_group(G, partition=None, use_edge_labels=True) noexcept:
src/sage/libs/coxeter3/coxeter.pxd: cpdef object full_context(self) noexcept
src/sage/libs/coxeter3/coxeter.pxd: cpdef CoxGroup parent_group(self) noexcept
src/sage/libs/coxeter3/coxeter.pyx: cpdef full_context(self) noexcept:
src/sage/libs/coxeter3/coxeter.pyx: cpdef CoxGroup parent_group(self) noexcept:
src/sage/libs/gap/element.pxd: cpdef UInt record_name_to_index(self, name) noexcept
src/sage/libs/gap/element.pyx: cpdef UInt record_name_to_index(self, name) noexcept:
src/sage/libs/sirocco.pyx:cpdef list[list] contpath_mp(int deg, list values, RealNumber y0r, RealNumber y0i, int prec) noexcept:
src/sage/libs/sirocco.pyx:cpdef list[list] contpath_mp_comps(int deg, list values, RealNumber y0r, RealNumber y0i, int prec, list otherdegs, list othercoefs) noexcept:
src/sage/libs/sirocco.pyx:cpdef list[list] contpath(int deg, list values, double y0r, double y0i) noexcept:
src/sage/libs/sirocco.pyx:cpdef list[list] contpath_comps(int deg, list values, double y0r, double y0i, list otherdegrees, list othercoefs) noexcept:
src/sage/matrix/matrix_gfpn_dense.pxd: cpdef fel_to_field(self, FEL x) noexcept
src/sage/matrix/matrix_gfpn_dense.pxd: cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j) noexcept
src/sage/matrix/matrix_gfpn_dense.pxd: cpdef list _rowlist_(self, i, j=*) noexcept
src/sage/matrix/matrix_gfpn_dense.pxd: cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right) noexcept
src/sage/matrix/matrix_gfpn_dense.pxd: cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=*) noexcept
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef fel_to_field(self, FEL x) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef fel_to_field(self, FEL x) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef _richcmp_(left, right, int op) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef list _rowlist_(self, i, j=-1) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef _add_(self, right) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef _sub_(self, right) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef _lmul_(self, Element right) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=0) noexcept:
src/sage/matrix/matrix_gfpn_dense.pyx: cpdef _echelon_in_place(self, str algorithm) noexcept:
so there are quite a few of these in the repo.
Originally posted by @dimpase in https://github.com/sagemath/sage/issues/37792#issuecomment-2058525010
It seems
cpdef
functions don't show warnings for misuse ofnoexcept
. We should investigate about this.