summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-04-12 12:45:23 (GMT)
committerGitHub <noreply@github.com>2024-04-12 12:45:23 (GMT)
commit2d3d9b4461d0e2cb475014868af3c2f241cb6495 (patch)
tree99ed8e6972a24598a116e62dd0b4639c9da4f18b
parent39a6b29756f98223d02d7bda5f5ed962c9e55328 (diff)
downloadcpython-2d3d9b4461d0e2cb475014868af3c2f241cb6495.zip
cpython-2d3d9b4461d0e2cb475014868af3c2f241cb6495.tar.gz
cpython-2d3d9b4461d0e2cb475014868af3c2f241cb6495.tar.bz2
gh-117764: Add docstrings and signatures for the types of None, Ellipsis and NotImplemented (GH-117813)
-rw-r--r--Lib/test/test_descr.py4
-rw-r--r--Lib/test/test_rlcompleter.py2
-rw-r--r--Objects/object.c14
-rw-r--r--Objects/sliceobject.c7
4 files changed, 21 insertions, 6 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 097ca38..92db088 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1687,10 +1687,10 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.assertEqual(d.foo(1), (d, 1))
self.assertEqual(D.foo(d, 1), (d, 1))
sm = staticmethod(None)
- self.assertEqual(sm.__dict__, {'__doc__': None})
+ self.assertEqual(sm.__dict__, {'__doc__': None.__doc__})
sm.x = 42
self.assertEqual(sm.x, 42)
- self.assertEqual(sm.__dict__, {"x" : 42, '__doc__': None})
+ self.assertEqual(sm.__dict__, {"x" : 42, '__doc__': None.__doc__})
del sm.x
self.assertNotHasAttr(sm, "x")
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index 273ce2c..1cff6a2 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -55,7 +55,7 @@ class TestRlcompleter(unittest.TestCase):
if x.startswith('s')])
self.assertEqual(self.stdcompleter.attr_matches('tuple.foospamegg'), [])
expected = sorted({'None.%s%s' % (x,
- '()' if x == '__init_subclass__'
+ '()' if x in ('__init_subclass__', '__class__')
else '' if x == '__doc__'
else '(')
for x in dir(None)})
diff --git a/Objects/object.c b/Objects/object.c
index c8e6f8f..17f75b4 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2007,6 +2007,11 @@ static PyNumberMethods none_as_number = {
0, /* nb_index */
};
+PyDoc_STRVAR(none_doc,
+"NoneType()\n"
+"--\n\n"
+"The type of the None singleton.");
+
PyTypeObject _PyNone_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NoneType",
@@ -2028,7 +2033,7 @@ PyTypeObject _PyNone_Type = {
0, /*tp_setattro */
0, /*tp_as_buffer */
Py_TPFLAGS_DEFAULT, /*tp_flags */
- 0, /*tp_doc */
+ none_doc, /*tp_doc */
0, /*tp_traverse */
0, /*tp_clear */
_Py_BaseObject_RichCompare, /*tp_richcompare */
@@ -2106,6 +2111,11 @@ static PyNumberMethods notimplemented_as_number = {
.nb_bool = notimplemented_bool,
};
+PyDoc_STRVAR(notimplemented_doc,
+"NotImplementedType()\n"
+"--\n\n"
+"The type of the NotImplemented singleton.");
+
PyTypeObject _PyNotImplemented_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NotImplementedType",
@@ -2127,7 +2137,7 @@ PyTypeObject _PyNotImplemented_Type = {
0, /*tp_setattro */
0, /*tp_as_buffer */
Py_TPFLAGS_DEFAULT, /*tp_flags */
- 0, /*tp_doc */
+ notimplemented_doc, /*tp_doc */
0, /*tp_traverse */
0, /*tp_clear */
0, /*tp_richcompare */
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 7333aea..245bea9 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -57,6 +57,11 @@ static PyMethodDef ellipsis_methods[] = {
{NULL, NULL}
};
+PyDoc_STRVAR(ellipsis_doc,
+"ellipsis()\n"
+"--\n\n"
+"The type of the Ellipsis singleton.");
+
PyTypeObject PyEllipsis_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"ellipsis", /* tp_name */
@@ -78,7 +83,7 @@ PyTypeObject PyEllipsis_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
+ ellipsis_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */