@@ -5155,10 +5155,22 @@ _PyLong_DivmodNear(PyObject *a, PyObject *b)
51555155 return NULL ;
51565156}
51575157
5158+ /*[clinic input]
5159+ int.__round__
5160+
5161+ ndigits as o_ndigits: object = NULL
5162+ /
5163+
5164+ Rounding an Integral returns itself.
5165+
5166+ Rounding with an ndigits argument also returns an integer.
5167+ [clinic start generated code]*/
5168+
51585169static PyObject *
5159- long_round (PyObject * self , PyObject * args )
5170+ int___round___impl (PyObject * self , PyObject * o_ndigits )
5171+ /*[clinic end generated code: output=954fda6b18875998 input=1614cf23ec9e18c3]*/
51605172{
5161- PyObject * o_ndigits = NULL , * temp , * result , * ndigits ;
5173+ PyObject * temp , * result , * ndigits ;
51625174
51635175 /* To round an integer m to the nearest 10**n (n positive), we make use of
51645176 * the divmod_near operation, defined by:
@@ -5174,8 +5186,6 @@ long_round(PyObject *self, PyObject *args)
51745186 *
51755187 * m - divmod_near(m, 10**n)[1].
51765188 */
5177- if (!PyArg_ParseTuple (args , "|O" , & o_ndigits ))
5178- return NULL ;
51795189 if (o_ndigits == NULL )
51805190 return long_long (self );
51815191
@@ -5536,9 +5546,7 @@ static PyMethodDef long_methods[] = {
55365546 "Flooring an Integral returns itself." },
55375547 {"__ceil__" , long_long_meth , METH_NOARGS ,
55385548 "Ceiling of an Integral returns itself." },
5539- {"__round__" , (PyCFunction )long_round , METH_VARARGS ,
5540- "Rounding an Integral returns itself.\n"
5541- "Rounding with an ndigits argument also returns an integer." },
5549+ INT___ROUND___METHODDEF
55425550 INT___GETNEWARGS___METHODDEF
55435551 INT___FORMAT___METHODDEF
55445552 INT___SIZEOF___METHODDEF
0 commit comments