python3-cysignals: update to 1.12.3.

This commit is contained in:
Gonzalo Tornaría 2025-01-30 08:42:56 -03:00 committed by Leah Neukirchen
parent b191f79033
commit aad68d7e48
3 changed files with 2 additions and 107 deletions

View file

@ -1,54 +0,0 @@
Taken from https://github.com/sagemath/cysignals/pull/222
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")

View file

@ -1,51 +0,0 @@
Taken from https://github.com/sagemath/cysignals/pull/222
diff --git a/src/cysignals/signals.pyx b/src/cysignals/signals.pyx
index 72f206e..96a99ad 100644
--- a/src/cysignals/signals.pyx
+++ b/src/cysignals/signals.pyx
@@ -25,7 +25,7 @@ See ``tests.pyx`` for extensive tests.
from libc.signal cimport *
from libc.stdio cimport freopen, stdin
-from cpython.ref cimport Py_XINCREF, Py_XDECREF
+from cpython.ref cimport Py_XINCREF, Py_CLEAR
from cpython.exc cimport (PyErr_Occurred, PyErr_NormalizeException,
PyErr_Fetch, PyErr_Restore)
from cpython.version cimport PY_MAJOR_VERSION
@@ -204,7 +204,7 @@ cdef int sig_raise_exception "sig_raise_exception"(int sig, const char* msg) exc
PyErr_Fetch(&typ, &val, &tb)
PyErr_NormalizeException(&typ, &val, &tb)
Py_XINCREF(val)
- Py_XDECREF(cysigs.exc_value)
+ Py_CLEAR(cysigs.exc_value)
cysigs.exc_value = val
PyErr_Restore(typ, val, tb)
@@ -362,8 +362,7 @@ cdef void verify_exc_value() noexcept:
"""
if cysigs.exc_value.ob_refcnt == 1:
# No other references => exception is certainly gone
- Py_XDECREF(cysigs.exc_value)
- cysigs.exc_value = NULL
+ Py_CLEAR(cysigs.exc_value)
return
if PyErr_Occurred() is not NULL:
@@ -394,8 +393,7 @@ cdef void verify_exc_value() noexcept:
pass
else:
if <PyObject*>handled is cysigs.exc_value:
- Py_XDECREF(cysigs.exc_value)
- cysigs.exc_value = NULL
+ Py_CLEAR(cysigs.exc_value)
return
# To be safe, we run the garbage collector because it may clear
@@ -411,5 +409,4 @@ cdef void verify_exc_value() noexcept:
# called again during garbage collection it might have already been set
# to NULL; see https://github.com/sagemath/cysignals/issues/126
if cysigs.exc_value != NULL and cysigs.exc_value.ob_refcnt == 1:
- Py_XDECREF(cysigs.exc_value)
- cysigs.exc_value = NULL
+ Py_CLEAR(cysigs.exc_value)

View file

@ -1,6 +1,6 @@
# Template file for 'python3-cysignals'
pkgname=python3-cysignals
version=1.12.2
version=1.12.3
revision=1
build_style=python3-pep517
build_helper=meson
@ -14,7 +14,7 @@ license="LGPL-3.0-or-later"
homepage="https://github.com/sagemath/cysignals"
changelog="https://github.com/sagemath/cysignals/releases"
distfiles="${PYPI_SITE}/c/cysignals/cysignals-${version}.tar.gz"
checksum=407db178fb18a91118ca742ede62000b2bee62b617eb49d26fcdad7e9ba2771a
checksum=89f7626dbf29db5ab3d6eff15a89978f4eb5193c320e9099bcc157dacdefd1eb
# cysignals must be compiled without _FORTIFY_SOURCE
CFLAGS="-U_FORTIFY_SOURCE"