Skip to content

Commit c95c93d

Browse files
authored
bpo-20285: Improve help docs for object (GH-4759)
1 parent f1e17e9 commit c95c93d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Lib/pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def spilldata(msg, attrs, predicate):
867867
thisclass = attrs[0][2]
868868
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
869869

870-
if thisclass is builtins.object:
870+
if object is not builtins.object and thisclass is builtins.object:
871871
attrs = inherited
872872
continue
873873
elif thisclass is object:
@@ -1327,7 +1327,7 @@ def spilldata(msg, attrs, predicate):
13271327
thisclass = attrs[0][2]
13281328
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
13291329

1330-
if thisclass is builtins.object:
1330+
if object is not builtins.object and thisclass is builtins.object:
13311331
attrs = inherited
13321332
continue
13331333
elif thisclass is object:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Expand object.__doc__ (docstring) to make it clearer.
2+
Modify pydoc.py so that help(object) lists object methods
3+
(for other classes, help omits methods of the object base class.)

Objects/typeobject.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,11 @@ static PyMethodDef object_methods[] = {
47504750
{0}
47514751
};
47524752

4753+
PyDoc_STRVAR(object_doc,
4754+
"object()\n--\n\n"
4755+
"The base class of the class hierarchy.\n\n"
4756+
"When called, it accepts no arguments and returns a new featureless\n"
4757+
"instance that has no instance attributes and cannot be given any.\n");
47534758

47544759
PyTypeObject PyBaseObject_Type = {
47554760
PyVarObject_HEAD_INIT(&PyType_Type, 0)
@@ -4772,7 +4777,7 @@ PyTypeObject PyBaseObject_Type = {
47724777
PyObject_GenericSetAttr, /* tp_setattro */
47734778
0, /* tp_as_buffer */
47744779
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
4775-
PyDoc_STR("object()\n--\n\nThe most base type"), /* tp_doc */
4780+
object_doc, /* tp_doc */
47764781
0, /* tp_traverse */
47774782
0, /* tp_clear */
47784783
object_richcompare, /* tp_richcompare */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy