From c6e7fe969dfbfe52746a2f9692bdf831b8ad892a Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Fri, 8 Dec 2017 20:31:53 -0500 Subject: [PATCH 1/4] bpo-20285: Improve help docs for object --- Lib/pydoc.py | 4 ++-- .../Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst | 1 + Objects/typeobject.c | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 01f7a32f454e51..06c9268f3f0342 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -873,7 +873,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: @@ -1319,7 +1319,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 00000000000000..3dcef3f6ab40b2 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst @@ -0,0 +1 @@ +Improve object.__doc__ and help(object) output. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 40c8fadc52ea94..38e554b93069a5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4703,6 +4703,8 @@ static PyMethodDef object_methods[] = { {0} }; +PyDoc_STRVAR(object_doc, +"object()\n--\n\nThe superclass for all Python classes."); PyTypeObject PyBaseObject_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -4725,7 +4727,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 */ From 6ea9419fe47ee0c435ea25b2cdbca4d2019e8e8e Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Fri, 22 Dec 2017 17:39:55 -0500 Subject: [PATCH 2/4] Requested changes. --- Objects/typeobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 38e554b93069a5..62bd1fcfa2002d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4704,7 +4704,8 @@ static PyMethodDef object_methods[] = { }; PyDoc_STRVAR(object_doc, -"object()\n--\n\nThe superclass for all Python classes."); +"object()\n--\n\nThe starting base class of all types and classes other\n" +"than itself."); PyTypeObject PyBaseObject_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) From cc583803a784e623ccc16e0e06a5c1cf9c1f0924 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 2 Feb 2018 01:27:20 -0500 Subject: [PATCH 3/4] Modify news. --- .../Documentation/2017-12-08-20-30-37.bpo-20285.cfnp0J.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 index 3dcef3f6ab40b2..ebe0c3f95e45ab 100644 --- 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 @@ -1 +1,3 @@ -Improve object.__doc__ and help(object) output. +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.) From 6abc7f3e7a92a2140e5026fd3d48849b0f269884 Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Mon, 12 Feb 2018 18:25:29 -0500 Subject: [PATCH 4/4] Improve docstring for object --- Objects/typeobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 62bd1fcfa2002d..a07ee0c648a3ea 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4704,8 +4704,10 @@ static PyMethodDef object_methods[] = { }; PyDoc_STRVAR(object_doc, -"object()\n--\n\nThe starting base class of all types and classes other\n" -"than itself."); +"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) 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