[Python-checkins] bpo-20285: Improve help docs for object (GH-4759)

Cheryl Sabella webhook-mailer at python.org
Fri May 24 06:43:35 EDT 2019


https://github.com/python/cpython/commit/c95c93d4eb0519beaa06e6b6e0ecca7c2a58f69c
commit: c95c93d4eb0519beaa06e6b6e0ecca7c2a58f69c
branch: master
author: Cheryl Sabella <cheryl.sabella at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-05-24T06:43:29-04:00
summary:

bpo-20285: Improve help docs for object (GH-4759)

files:
A Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst
M Lib/pydoc.py
M Objects/typeobject.c

diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 86ccfe041f66..679a596821f4 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -867,7 +867,7 @@ def spilldata(msg, attrs, predicate):
                 thisclass = attrs[0][2]
             attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
 
-            if thisclass is builtins.object:
+            if object is not builtins.object and thisclass is builtins.object:
                 attrs = inherited
                 continue
             elif thisclass is object:
@@ -1327,7 +1327,7 @@ def spilldata(msg, attrs, predicate):
                 thisclass = attrs[0][2]
             attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
 
-            if thisclass is builtins.object:
+            if object is not builtins.object and thisclass is builtins.object:
                 attrs = inherited
                 continue
             elif thisclass is object:
diff --git a/Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst b/Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst
new file mode 100644
index 000000000000..ebe0c3f95e45
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst
@@ -0,0 +1,3 @@
+Expand object.__doc__ (docstring) to make it clearer.
+Modify pydoc.py so that help(object) lists object methods
+(for other classes, help omits methods of the object base class.)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 49b45b8518cc..339f7285292c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4750,6 +4750,11 @@ static PyMethodDef object_methods[] = {
     {0}
 };
 
+PyDoc_STRVAR(object_doc,
+"object()\n--\n\n"
+"The base class of the class hierarchy.\n\n"
+"When called, it accepts no arguments and returns a new featureless\n"
+"instance that has no instance attributes and cannot be given any.\n");
 
 PyTypeObject PyBaseObject_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
@@ -4772,7 +4777,7 @@ PyTypeObject PyBaseObject_Type = {
     PyObject_GenericSetAttr,                    /* tp_setattro */
     0,                                          /* tp_as_buffer */
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   /* tp_flags */
-    PyDoc_STR("object()\n--\n\nThe most base type"),  /* tp_doc */
+    object_doc,                                 /* tp_doc */
     0,                                          /* tp_traverse */
     0,                                          /* tp_clear */
     object_richcompare,                         /* tp_richcompare */



More information about the Python-checkins mailing list