[Python-checkins] gh-96364: Fix text signatures of `__getitem__` for `list` and `dict` (GH-96365)

methane webhook-mailer at python.org
Fri Sep 9 04:37:13 EDT 2022


https://github.com/python/cpython/commit/30cc1901efa18180a83bf8402df9e1c10d877c49
commit: 30cc1901efa18180a83bf8402df9e1c10d877c49
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: methane <songofacandy at gmail.com>
date: 2022-09-09T17:37:02+09:00
summary:

gh-96364: Fix text signatures of `__getitem__` for `list` and `dict` (GH-96365)

files:
A Misc/NEWS.d/next/Core and Builtins/2022-08-29-00-37-21.gh-issue-96364.c-IVyb.rst
M Objects/dictobject.c
M Objects/listobject.c

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 00000000000..8872f9a5a49
--- /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 0cb95d52360..c603e6f1f87 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 9afa68f9fe1..6005466f95f 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



More information about the Python-checkins mailing list