]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-152870: Fix compile error with decimal when EXTRA_FUNCTIONALITY enabled...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 3 Jul 2026 11:03:07 +0000 (13:03 +0200)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 11:03:07 +0000 (11:03 +0000)
gh-152870: Fix compile error with decimal when EXTRA_FUNCTIONALITY enabled (GH-152871)
(cherry picked from commit c4739533f335f9cd4fa71ba6daff2a81751da643)

Co-authored-by: Xiaowei Lu <weixlu420302@gmail.com>
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 2760792a3fe18ed9e93e39e64d727ec606377d15..7a3240a3636a9cbe55ac1f9a86fdb6a1afbe27e9 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