Skip to content

Commit 2a7eb3d

Browse files
[3.15] gh-152870: Fix compile error with decimal when EXTRA_FUNCTIONALITY enabled (GH-152871) (#152937)
gh-152870: Fix compile error with decimal when EXTRA_FUNCTIONALITY enabled (GH-152871) (cherry picked from commit c473953) Co-authored-by: Xiaowei Lu <weixlu420302@gmail.com>
1 parent 1b89ad7 commit 2a7eb3d

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lib/test/test_decimal.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4967,6 +4967,14 @@ def test_c_context(self):
49674967
self.assertEqual(c._flags, C.DecClamped)
49684968
self.assertEqual(c._traps, C.DecRounded)
49694969

4970+
@requires_extra_functionality
4971+
def test_c_context_apply(self):
4972+
c = C.Context(prec=3)
4973+
self.assertEqual(c.apply(C.Decimal('1.23456')), C.Decimal('1.23'))
4974+
# A higher precision won't see them as equal.
4975+
c = C.Context(prec=5)
4976+
self.assertNotEqual(c.apply(C.Decimal('1.23456')), C.Decimal('1.23'))
4977+
49704978
@requires_extra_functionality
49714979
def test_constants(self):
49724980
# Condition flags
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix a compilation error in the :mod:`decimal` C extension (``_decimal``) when
2+
it is built with ``EXTRA_FUNCTIONALITY``. ``Context.apply()`` called the
3+
internal ``_apply`` helper using its pre-Argument-Clinic signature; the call is
4+
now made through the generated ``_impl`` function.

Modules/_decimal/_decimal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6993,7 +6993,7 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls,
69936993
PyObject *x)
69946994
/*[clinic end generated code: output=f8a7142d47ad4ff3 input=388e66ca82733516]*/
69956995
{
6996-
return _decimal_Context__apply(context, x);
6996+
return _decimal_Context__apply_impl(context, cls, x);
69976997
}
69986998
#endif
69996999

0 commit comments

Comments
 (0)