From eecc267734b5a00d7ff333155853185ff5a8d72a Mon Sep 17 00:00:00 2001 From: Chenxin Zhong Date: Fri, 5 Dec 2025 21:44:33 +0800 Subject: [PATCH 1/3] add doctests tolerance Updated doctest output to clarify expected behavior of interruptible_sleep function. --- src/sage/doctest/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py index 46975c072cb..4906ac17dbc 100644 --- a/src/sage/doctest/util.py +++ b/src/sage/doctest/util.py @@ -843,10 +843,10 @@ def ensure_interruptible_after(seconds: float, max_wait_after_interrupt: float = ....: if start_time.tv_sec > target_time.tv_sec or (start_time.tv_sec == target_time.tv_sec and start_time.tv_nsec >= target_time.tv_nsec): ....: break ....: ''') - sage: with ensure_interruptible_after(2) as data: interruptible_sleep(1r) + sage: with ensure_interruptible_after(2) as data: interruptible_sleep(1r) # abs tol 0.1 Traceback (most recent call last): ... - RuntimeError: Function terminates early after 1.00... < 2.0000 seconds + RuntimeError: Function terminates early after 1.0000 < 2.0000 seconds sage: with ensure_interruptible_after(1) as data: uninterruptible_sleep(2r) Traceback (most recent call last): ... From 4d039db0fa8fe6ab03690fedb6bde36ee18628a0 Mon Sep 17 00:00:00 2001 From: Chenxin Zhong Date: Fri, 5 Dec 2025 23:13:53 +0800 Subject: [PATCH 2/3] Modify doctest for ensure_interruptible_after function Updated doctest to reflect changes in RuntimeError messages and added output for 'data'. --- src/sage/doctest/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py index 4906ac17dbc..4c68677beae 100644 --- a/src/sage/doctest/util.py +++ b/src/sage/doctest/util.py @@ -846,7 +846,9 @@ def ensure_interruptible_after(seconds: float, max_wait_after_interrupt: float = sage: with ensure_interruptible_after(2) as data: interruptible_sleep(1r) # abs tol 0.1 Traceback (most recent call last): ... - RuntimeError: Function terminates early after 1.0000 < 2.0000 seconds + RuntimeError: Function terminates early after ... < 2.0000 seconds + sage: data # abs tol 0.1 + {'alarm_raised': False, 'elapsed': 1.0} sage: with ensure_interruptible_after(1) as data: uninterruptible_sleep(2r) Traceback (most recent call last): ... From 78f79cf5e826b6121a3819fff94eaf9b7fe88b6f Mon Sep 17 00:00:00 2001 From: Chenxin Zhong Date: Fri, 5 Dec 2025 23:14:45 +0800 Subject: [PATCH 3/3] Modify doctest for interruptible_sleep function Updated doctest to remove absolute tolerance in interruptible_sleep. --- src/sage/doctest/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py index 4c68677beae..7f2f895a76a 100644 --- a/src/sage/doctest/util.py +++ b/src/sage/doctest/util.py @@ -843,7 +843,7 @@ def ensure_interruptible_after(seconds: float, max_wait_after_interrupt: float = ....: if start_time.tv_sec > target_time.tv_sec or (start_time.tv_sec == target_time.tv_sec and start_time.tv_nsec >= target_time.tv_nsec): ....: break ....: ''') - sage: with ensure_interruptible_after(2) as data: interruptible_sleep(1r) # abs tol 0.1 + sage: with ensure_interruptible_after(2) as data: interruptible_sleep(1r) Traceback (most recent call last): ... RuntimeError: Function terminates early after ... < 2.0000 seconds