]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152870: Fix compile error with decimal when EXTRA_FUNCTIONALITY enabled (#152871)
authorXiaowei Lu <weixlu420302@gmail.com>
Fri, 3 Jul 2026 10:34:15 +0000 (18:34 +0800)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 10:34:15 +0000 (13:34 +0300)
Lib/test/test_decimal.py
Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst [new file with mode: 0644]
Modules/_decimal/_decimal.c

index fe8c8ce12da0bfa42f5df59b34f9bb3a9a2b9164..a04ed0c83c07c4a272ebcea6eb9cdb9a84f56287 100644 (file)
@@ -4967,6 +4967,14 @@ class CFunctionality(unittest.TestCase):
         self.assertEqual(c._flags, C.DecClamped)
         self.assertEqual(c._traps, C.DecRounded)
 
+    @requires_extra_functionality
+    def test_c_context_apply(self):
+        c = C.Context(prec=3)
+        self.assertEqual(c.apply(C.Decimal('1.23456')), C.Decimal('1.23'))
+        # A higher precision won't see them as equal.
+        c = C.Context(prec=5)
+        self.assertNotEqual(c.apply(C.Decimal('1.23456')), C.Decimal('1.23'))
+
     @requires_extra_functionality
     def test_constants(self):
         # Condition flags
diff --git a/Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst b/Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst
new file mode 100644 (file)
index 0000000..eaddd22
--- /dev/null
@@ -0,0 +1,4 @@
+Fix a compilation error in the :mod:`decimal` C extension (``_decimal``) when
+it is built with ``EXTRA_FUNCTIONALITY``. ``Context.apply()`` called the
+internal ``_apply`` helper using its pre-Argument-Clinic signature; the call is
+now made through the generated ``_impl`` function.
index 4db1b60be77844d0abd61fedff82302a76fee6a9..dc1b3c06bed9521470d5d63aa32987bccad25dc3 100644 (file)
@@ -6993,7 +6993,7 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls,
                             PyObject *x)
 /*[clinic end generated code: output=f8a7142d47ad4ff3 input=388e66ca82733516]*/
 {
-    return _decimal_Context__apply(context, x);
+    return _decimal_Context__apply_impl(context, cls, x);
 }
 #endif