diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-08-29-00-37-21.gh-issue-96364.c-IVyb.rst b/Misc/NEWS.d/next/Core and Builtins/2022-08-29-00-37-21.gh-issue-96364.c-IVyb.rst new file mode 100644 index 00000000000000..8872f9a5a498d5 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-08-29-00-37-21.gh-issue-96364.c-IVyb.rst @@ -0,0 +1 @@ +Fix text signatures of ``list.__getitem__`` and ``dict.__getitem__``. diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 0cb95d52360ef1..c603e6f1f87449 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3591,7 +3591,8 @@ dict_ior(PyObject *self, PyObject *other) return self; } -PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]"); +PyDoc_STRVAR(getitem__doc__, +"__getitem__($self, key, /)\n--\n\nReturn self[key]."); PyDoc_STRVAR(sizeof__doc__, "D.__sizeof__() -> size of D in memory, in bytes"); diff --git a/Objects/listobject.c b/Objects/listobject.c index 9afa68f9fe100c..6005466f95fdb1 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2824,7 +2824,8 @@ static PyObject *list_iter(PyObject *seq); static PyObject *list_subscript(PyListObject*, PyObject*); static PyMethodDef list_methods[] = { - {"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, "x.__getitem__(y) <==> x[y]"}, + {"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, + PyDoc_STR("__getitem__($self, index, /)\n--\n\nReturn self[index].")}, LIST___REVERSED___METHODDEF LIST___SIZEOF___METHODDEF LIST_CLEAR_METHODDEF