diff --git a/pyproject.toml b/pyproject.toml index d30ad23..edcb5c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,4 +34,4 @@ requires-python = ">=3.9" [tool.pytest.ini_options] addopts = "--doctest-modules --import-mode importlib" -norecursedirs = "builddir docs example" +testpaths = "src tests" diff --git a/src/cysignals/implementation.c b/src/cysignals/implementation.c index 20a83d0..18b8144 100644 --- a/src/cysignals/implementation.c +++ b/src/cysignals/implementation.c @@ -591,7 +591,7 @@ static void _sig_on_interrupt_received(void) do_raise_exception(cysigs.interrupt_received); cysigs.sig_on_count = 0; cysigs.interrupt_received = 0; - custom_signal_unblock(); + custom_set_pending_signal(0); #if HAVE_SIGPROCMASK sigprocmask(SIG_SETMASK, &oldset, NULL); diff --git a/tests/test_custom_signals.py b/tests/test_custom_signals.py new file mode 100644 index 0000000..0afc36f --- /dev/null +++ b/tests/test_custom_signals.py @@ -0,0 +1,23 @@ +""" +Tests for custom signals. +""" + +import time +import pytest + +def test_clear_pending(): + """ + Regression test for https://github.com/sagemath/cysignals/pull/216 + """ + + alarm = pytest.importorskip("cysignals.alarm") # n/a on windows + cypari2 = pytest.importorskip("cypari2") + + with pytest.raises(alarm.AlarmInterrupt): + alarm.alarm(0.01) + time.sleep(1) + + try: + cypari2.Pari() + except alarm.AlarmInterrupt: + pytest.fail("AlarmInterrupt was not cleared")