Skip to content

Commit 860a942

Browse files
committed
gh-73487: Convert _decimal to use Argument Clinic (part 7)
Use "defining class" converter, where possible.
1 parent ef4dd1d commit 860a942

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

Modules/_decimal/_decimal.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,6 +4042,7 @@ _decimal_Decimal_as_integer_ratio_impl(PyObject *self)
40424042
/*[clinic input]
40434043
_decimal.Decimal.to_integral_value
40444044
4045+
cls: defining_class
40454046
rounding: object = None
40464047
context: object = None
40474048
@@ -4053,15 +4054,16 @@ rounding mode of the current default context is used.
40534054
[clinic start generated code]*/
40544055

40554056
static PyObject *
4056-
_decimal_Decimal_to_integral_value_impl(PyObject *self, PyObject *rounding,
4057+
_decimal_Decimal_to_integral_value_impl(PyObject *self, PyTypeObject *cls,
4058+
PyObject *rounding,
40574059
PyObject *context)
4058-
/*[clinic end generated code: output=7301465765f48b6b input=04e2312d5ed19f77]*/
4060+
/*[clinic end generated code: output=23047d848ef84db1 input=85aa9499a21ea8d7]*/
40594061
{
40604062
PyObject *result;
40614063
uint32_t status = 0;
40624064
mpd_context_t workctx;
40634065

4064-
decimal_state *state = get_module_state_by_def(Py_TYPE(self));
4066+
decimal_state *state = PyType_GetModuleState(cls);
40654067
CONTEXT_CHECK_VA(state, context);
40664068

40674069
workctx = *CTX(context);
@@ -4099,11 +4101,12 @@ versions.
40994101
[clinic start generated code]*/
41004102

41014103
static PyObject *
4102-
_decimal_Decimal_to_integral_impl(PyObject *self, PyObject *rounding,
4103-
PyObject *context)
4104-
/*[clinic end generated code: output=a0c7188686ee7f5c input=709b54618ecd0d8b]*/
4104+
_decimal_Decimal_to_integral_impl(PyObject *self, PyTypeObject *cls,
4105+
PyObject *rounding, PyObject *context)
4106+
/*[clinic end generated code: output=5dac8f54c2a3ed26 input=709b54618ecd0d8b]*/
41054107
{
4106-
return _decimal_Decimal_to_integral_value_impl(self, rounding, context);
4108+
return _decimal_Decimal_to_integral_value_impl(self, cls, rounding,
4109+
context);
41074110
}
41084111

41094112
/*[clinic input]
@@ -4118,9 +4121,10 @@ given, then the rounding mode of the current default context is used.
41184121
[clinic start generated code]*/
41194122

41204123
static PyObject *
4121-
_decimal_Decimal_to_integral_exact_impl(PyObject *self, PyObject *rounding,
4124+
_decimal_Decimal_to_integral_exact_impl(PyObject *self, PyTypeObject *cls,
4125+
PyObject *rounding,
41224126
PyObject *context)
4123-
/*[clinic end generated code: output=8b004f9b45ac7746 input=fabce7a744b8087c]*/
4127+
/*[clinic end generated code: output=543a39a02eea9917 input=fabce7a744b8087c]*/
41244128
{
41254129
PyObject *result;
41264130
uint32_t status = 0;

Modules/_decimal/clinic/_decimal.c.h

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)