]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117764: Add docstrings and signatures for the types of None, Ellipsis and NotImple...
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 12 Apr 2024 12:45:23 +0000 (15:45 +0300)
committerGitHub <noreply@github.com>
Fri, 12 Apr 2024 12:45:23 +0000 (15:45 +0300)
Lib/test/test_descr.py
Lib/test/test_rlcompleter.py
Objects/object.c
Objects/sliceobject.c

index 097ca38e0b1ed8f9986b18cc6ac7511e7453774e..92db0886793261b71f716e98214c93f77cdaac8b 100644 (file)
@@ -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")
 
index 273ce2cf5c7dd27ee8482dc766cc70cd0cf8dd63..1cff6a218f8d756ea4dd113d38e11304e0c814a8 100644 (file)
@@ -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)})
index c8e6f8fc1a2b40e2dc8b2894666d0d2a56aaa474..17f75b43e82d3ada2e5e4996369cd48b53e6ef1e 100644 (file)
@@ -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 */
index 7333aea91e5648af0249073be1e2ab6a4eb381a8..245bea98d585093c31397011239b792ef0738d5d 100644 (file)
@@ -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 */