[Python-checkins] (no subject)

Łukasz Langa webhook-mailer at python.org
Tue Jul 2 07:32:47 EDT 2019




To: python-checkins at python.org
Subject: Stop using Argument Clinic for dict_pop (GH-13935)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/d4c664736e43284405100d98d516fa269a64=
7461
commit: d4c664736e43284405100d98d516fa269a647461
branch: 3.8
author: Inada Naoki <songofacandy at gmail.com>
committer: =C5=81ukasz Langa <lukasz at langa.pl>
date: 2019-07-02T13:32:43+02:00
summary:

Stop using Argument Clinic for dict_pop (GH-13935)

files:
M Objects/clinic/dictobject.c.h
M Objects/dictobject.c

diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index b87244d87348..8d5493330835 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -116,42 +116,6 @@ dict_setdefault(PyDictObject *self, PyObject *const *arg=
s, Py_ssize_t nargs)
     return return_value;
 }
=20
-PyDoc_STRVAR(dict_pop__doc__,
-"pop($self, key, default=3DNone, /)\n"
-"--\n"
-"\n"
-"Remove specified key and return the corresponding value.\n"
-"\n"
-"If key is not found, default is returned if given, otherwise KeyError is ra=
ised");
-
-#define DICT_POP_METHODDEF    \
-    {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__d=
oc__},
-
-static PyObject *
-dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
-
-static PyObject *
-dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
-{
-    PyObject *return_value =3D NULL;
-    PyObject *key;
-    PyObject *default_value =3D NULL;
-
-    if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
-        goto exit;
-    }
-    key =3D args[0];
-    if (nargs < 2) {
-        goto skip_optional;
-    }
-    default_value =3D args[1];
-skip_optional:
-    return_value =3D dict_pop_impl(self, key, default_value);
-
-exit:
-    return return_value;
-}
-
 PyDoc_STRVAR(dict_popitem__doc__,
 "popitem($self, /)\n"
 "--\n"
@@ -190,4 +154,4 @@ dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED=
(ignored))
 {
     return dict___reversed___impl(self);
 }
-/*[clinic end generated code: output=3D0fd5cafc61a51d3c input=3Da9049054013a=
1b77]*/
+/*[clinic end generated code: output=3D676532dcc941d399 input=3Da9049054013a=
1b77]*/
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 0cc144375006..e417cd2119c6 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2987,23 +2987,37 @@ dict_clear(PyDictObject *mp, PyObject *Py_UNUSED(igno=
red))
     Py_RETURN_NONE;
 }
=20
-/*[clinic input]
-dict.pop
-
-    key: object
-    default: object =3D NULL
-    /
+/*
+We don't use Argument Clinic for dict.pop because it doesn't support
+custom signature for now.
+*/
+PyDoc_STRVAR(dict_pop__doc__,
+"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.=
\n\
+If key is not found, d is returned if given, otherwise KeyError is raised");
=20
-Remove specified key and return the corresponding value.
-
-If key is not found, default is returned if given, otherwise KeyError is rai=
sed
-[clinic start generated code]*/
+#define DICT_POP_METHODDEF    \
+    {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__d=
oc__},
=20
 static PyObject *
-dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value)
-/*[clinic end generated code: output=3D3abb47b89f24c21c input=3D016f6a000e4e=
633b]*/
+dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
 {
-    return _PyDict_Pop((PyObject*)self, key, default_value);
+    PyObject *return_value =3D NULL;
+    PyObject *key;
+    PyObject *default_value =3D NULL;
+
+    if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
+        goto exit;
+    }
+    key =3D args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    default_value =3D args[1];
+skip_optional:
+    return_value =3D _PyDict_Pop((PyObject*)self, key, default_value);
+
+exit:
+    return return_value;
 }
=20
 /*[clinic input]



More information about the Python-checkins mailing list