summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-07-20 12:57:37 (GMT)
committerGitHub <noreply@github.com>2020-07-20 12:57:37 (GMT)
commit5a2bac7fe0e7a2b67fd57c7a9176a50feed0d7a0 (patch)
treee984dc116ae6a1496282d81b108caa29f898ff78 /Objects/longobject.c
parent12f433411bba8a0cdc4f09ba34472745ae9da0d1 (diff)
downloadcpython-5a2bac7fe0e7a2b67fd57c7a9176a50feed0d7a0.zip
cpython-5a2bac7fe0e7a2b67fd57c7a9176a50feed0d7a0.tar.gz
cpython-5a2bac7fe0e7a2b67fd57c7a9176a50feed0d7a0.tar.bz2
bpo-41342: Convert int.__round__ to Argument Clinic (GH-21549)
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 571f53a..92514d4 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5155,10 +5155,22 @@ _PyLong_DivmodNear(PyObject *a, PyObject *b)
return NULL;
}
+/*[clinic input]
+int.__round__
+
+ ndigits as o_ndigits: object = NULL
+ /
+
+Rounding an Integral returns itself.
+
+Rounding with an ndigits argument also returns an integer.
+[clinic start generated code]*/
+
static PyObject *
-long_round(PyObject *self, PyObject *args)
+int___round___impl(PyObject *self, PyObject *o_ndigits)
+/*[clinic end generated code: output=954fda6b18875998 input=1614cf23ec9e18c3]*/
{
- PyObject *o_ndigits=NULL, *temp, *result, *ndigits;
+ PyObject *temp, *result, *ndigits;
/* To round an integer m to the nearest 10**n (n positive), we make use of
* the divmod_near operation, defined by:
@@ -5174,8 +5186,6 @@ long_round(PyObject *self, PyObject *args)
*
* m - divmod_near(m, 10**n)[1].
*/
- if (!PyArg_ParseTuple(args, "|O", &o_ndigits))
- return NULL;
if (o_ndigits == NULL)
return long_long(self);
@@ -5536,9 +5546,7 @@ static PyMethodDef long_methods[] = {
"Flooring an Integral returns itself."},
{"__ceil__", long_long_meth, METH_NOARGS,
"Ceiling of an Integral returns itself."},
- {"__round__", (PyCFunction)long_round, METH_VARARGS,
- "Rounding an Integral returns itself.\n"
- "Rounding with an ndigits argument also returns an integer."},
+ INT___ROUND___METHODDEF
INT___GETNEWARGS___METHODDEF
INT___FORMAT___METHODDEF
INT___SIZEOF___METHODDEF