From 4bf2d1419434fc6980828429c82cc5a8f570fc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 23 Oct 2026 12:59:23 -0700 Subject: [PATCH] gh-140036: Test modulo and divmod of pure Python Decimal in unbounded contexts Check that `%` and `divmod()` stay fast when the context precision is `MAX_PREC`, as `//` already is. --- Lib/test/test_decimal.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 6d68ba456fcdf8..424d3f577e9f87 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4769,6 +4769,16 @@ def test_divide_unbound_context(self): x = self.decimal.Decimal('1') y = x // 1 # should be fast + def test_modulo_unbound_context(self): + with self.unbound_context() as c: + x = self.decimal.Decimal('1') + y = x % 1 # should be fast + + def test_divmod_unbound_context(self): + with self.unbound_context() as c: + x = self.decimal.Decimal('1') + y = divmod(x, 1) # should be fast + def test_remainder_near(self): L = 1000 limit = sys.get_int_max_str_digits()