Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-117764: Add docstrings and signatures for the types of None, Ellipsis and NotImplemented #117813

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,10 +1687,10 @@ class D(C):
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")

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_rlcompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_attr_matches(self):
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)})
Expand Down
14 changes: 12 additions & 2 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 */
Expand Down Expand Up @@ -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",
Expand All @@ -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 */
Expand Down
7 changes: 6 additions & 1 deletion Objects/sliceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down
Loading