Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4967,6 +4967,14 @@ def test_c_context(self):
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading