From ed4be7a1d12a9af72b8d5102d289ba5ca904209c Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Wed, 4 Oct 2023 14:29:43 +0100 Subject: [PATCH 1/2] make docbuld more robust currently make doc fails; this is a fix that runs sphinx on already installed package. --- Makefile | 2 +- docs/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c4d3829b..c7e4764d 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ dist: configure chmod -R go+rX-w . umask 0022 && $(PYTHON) setup.py sdist --formats=gztar -doc: +doc: install cd docs && $(MAKE) html diff --git a/docs/Makefile b/docs/Makefile index 127c5da1..2b098704 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build +SPHINXBUILD = python3 $(shell which sphinx-build) PAPER = BUILDDIR = build From 0ebd0a7641b3cfe72afff3315bc1a80513f3555c Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Wed, 4 Oct 2023 15:36:16 +0100 Subject: [PATCH 2/2] add explicit noexcept's --- src/cysignals/memory.pxd | 10 +++++----- src/cysignals/signals.pxd.in | 20 ++++++++++---------- src/cysignals/signals.pyx | 8 ++++---- src/cysignals/tests.pyx | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/cysignals/memory.pxd b/src/cysignals/memory.pxd index 9994cee9..5cb5284a 100644 --- a/src/cysignals/memory.pxd +++ b/src/cysignals/memory.pxd @@ -33,35 +33,35 @@ cdef extern from *: int unlikely(int) nogil # Defined by Cython -cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil: +cdef inline void* sig_malloc "sig_malloc"(size_t n) noexcept nogil: sig_block() cdef void* ret = malloc(n) sig_unblock() return ret -cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil: +cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) noexcept nogil: sig_block() cdef void* ret = realloc(ptr, size) sig_unblock() return ret -cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil: +cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) noexcept nogil: sig_block() cdef void* ret = calloc(nmemb, size) sig_unblock() return ret -cdef inline void sig_free "sig_free"(void* ptr) nogil: +cdef inline void sig_free "sig_free"(void* ptr) noexcept nogil: sig_block() free(ptr) sig_unblock() @cython.cdivision(True) -cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil: +cdef inline size_t mul_overflowcheck(size_t a, size_t b) noexcept nogil: """ Return a*b, checking for overflow. Assume that a > 0. If overflow occurs, return (-1). diff --git a/src/cysignals/signals.pxd.in b/src/cysignals/signals.pxd.in index 3a536907..aefb1a30 100644 --- a/src/cysignals/signals.pxd.in +++ b/src/cysignals/signals.pxd.in @@ -50,9 +50,9 @@ cdef extern from "macros.h" nogil: int sig_check_no_except "sig_check"() # This function adds custom block/unblock/pending. -cdef int add_custom_signals(int (*custom_signal_is_blocked)(), - void (*custom_signal_unblock)(), - void (*custom_set_pending_signal)(int)) except -1 +cdef int add_custom_signals(int (*custom_signal_is_blocked)() noexcept, + void (*custom_signal_unblock)() noexcept, + void (*custom_set_pending_signal)(int) noexcept) except -1 # This function does nothing, but it is declared cdef except *, so it # can be used to make Cython check whether there is a pending exception @@ -62,9 +62,9 @@ cdef inline void cython_check_exception() except * nogil: pass -cdef void verify_exc_value() +cdef void verify_exc_value() noexcept -cdef inline PyObject* sig_occurred(): +cdef inline PyObject* sig_occurred() noexcept: """ Borrowed reference to the exception which is currently being propagated from cysignals. If there is no exception or if we @@ -88,13 +88,13 @@ cdef inline PyObject* sig_occurred(): # these available to every Cython module cimporting this file. cdef nogil: cysigs_t cysigs "cysigs" - void _sig_on_interrupt_received "_sig_on_interrupt_received"() - void _sig_on_recover "_sig_on_recover"() - void _sig_off_warning "_sig_off_warning"(const char*, int) - void print_backtrace "print_backtrace"() + void _sig_on_interrupt_received "_sig_on_interrupt_received"() noexcept + void _sig_on_recover "_sig_on_recover"() noexcept + void _sig_off_warning "_sig_off_warning"(const char*, int) noexcept + void print_backtrace "print_backtrace"() noexcept -cdef inline void __generate_declarations(): +cdef inline void __generate_declarations() noexcept: cysigs _sig_on_interrupt_received _sig_on_recover diff --git a/src/cysignals/signals.pyx b/src/cysignals/signals.pyx index 04cf60e5..114a156f 100644 --- a/src/cysignals/signals.pyx +++ b/src/cysignals/signals.pyx @@ -80,9 +80,9 @@ def _pari_version(): return v.decode('ascii') -cdef int add_custom_signals(int (*custom_signal_is_blocked)(), - void (*custom_signal_unblock)(), - void (*custom_set_pending_signal)(int)) except -1: +cdef int add_custom_signals(int (*custom_signal_is_blocked)() noexcept, + void (*custom_signal_unblock)() noexcept, + void (*custom_set_pending_signal)(int) noexcept) except -1: """ Add an external block/unblock/pending to cysignals. @@ -341,7 +341,7 @@ def python_check_interrupt(sig, frame): sig_check() -cdef void verify_exc_value(): +cdef void verify_exc_value() noexcept: """ Check that ``cysigs.exc_value`` is still the exception being raised. Clear ``cysigs.exc_value`` if not. diff --git a/src/cysignals/tests.pyx b/src/cysignals/tests.pyx index 4e9b433c..34629152 100644 --- a/src/cysignals/tests.pyx +++ b/src/cysignals/tests.pyx @@ -89,14 +89,14 @@ set_debug_level(0) ######################################################################## # C helper functions # ######################################################################## -cdef void infinite_loop() nogil: +cdef void infinite_loop() noexcept nogil: # Ensure that the compiler cannot "optimize away" this infinite # loop, see https://bugs.llvm.org/show_bug.cgi?id=965 cdef volatile_int x = 0 while x == 0: pass -cdef void infinite_malloc_loop() nogil: +cdef void infinite_malloc_loop() noexcept nogil: cdef size_t s = 1 while True: sig_free(sig_malloc(s)) @@ -106,12 +106,12 @@ cdef void infinite_malloc_loop() nogil: # Dereference a NULL pointer on purpose. This signals a SIGSEGV on most # systems, but on older Mac OS X and possibly other systems, this # signals a SIGBUS instead. In any case, this should give some signal. -cdef void dereference_null_pointer() nogil: +cdef void dereference_null_pointer() noexcept nogil: cdef volatile_int* ptr = (0) ptr[0] += 1 -cdef int stack_overflow(volatile_int* x=NULL) nogil: +cdef int stack_overflow(volatile_int* x=NULL) noexcept nogil: cdef volatile_int a = 0 if x is not NULL: a = x[0] @@ -258,7 +258,7 @@ def test_sig_str(long delay=DEFAULT_DELAY): signal_after_delay(SIGABRT, delay) infinite_loop() -cdef c_test_sig_on_cython(): +cdef c_test_sig_on_cython() noexcept: sig_on() infinite_loop()