diff options
Diffstat (limited to 'docs/src/userguide/language_basics.rst')
-rw-r--r-- | docs/src/userguide/language_basics.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/src/userguide/language_basics.rst b/docs/src/userguide/language_basics.rst index 0fdd87783..c3b9f36e4 100644 --- a/docs/src/userguide/language_basics.rst +++ b/docs/src/userguide/language_basics.rst @@ -414,6 +414,17 @@ use this form, since there isn't any error return value to test. Otherwise, an explicit error return value allows the C compiler to generate more efficient code and is thus generally preferable. +To explicitly mark a function as not returning an exception use +``noexcept``. + + cdef int spam() noexcept: + ... + +This is worth doing because (a) "explicit is better than implicit", and +(b) the default behaviour for ``cdef`` functions will change in Cython 3.0 +so that functions will propagate exceptions by default. Therefore, it is +best to mark them now if you want them to swallow exceptions in the future. + An external C++ function that may raise an exception can be declared with:: cdef int spam() except + |