mirror of
https://github.com/python/cpython.git
synced 2026-07-11 04:21:21 -04:00
[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 c4739533f3)
Co-authored-by: Xiaowei Lu <weixlu420302@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1b89ad7e00
commit
2a7eb3d179
@@ -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
|
||||
|
||||
@@ -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.
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user