-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-20285: Improve help docs for object #4759
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
Changes from 4 commits
c6e7fe9
6ea9419
5b4d0e6
cc58380
6abc7f3
fce40fe
51b59fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4707,6 +4707,9 @@ static PyMethodDef object_methods[] = { | |
{0} | ||
}; | ||
|
||
PyDoc_STRVAR(object_doc, | ||
"object()\n--\n\nThe starting base class of all types and classes other\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not familiar with docstrings in C code, but it appears that 'classname()\n--\n\n' gets removed before making the rest into the class object doc attribute. |
||
"than itself."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first line of a docstring, if not too long, should not have an embedded \n. So I think this should have been written "object()\n--\n\n" My suggested replacement would then be "object()\n--\n\n" A limit of 72 columns with a 4 column indent allows 68 chars. The longest above is 66. |
||
|
||
PyTypeObject PyBaseObject_Type = { | ||
PyVarObject_HEAD_INIT(&PyType_Type, 0) | ||
|
@@ -4729,7 +4732,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 */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The have
help(object)
print the methods defined onobject
, the same as it does for every other class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One confusing thing about this module is that the argument that the docs are being created for is named is object. So, for this PR, object both can refer to the name of the argument and the class called object.
thisclass
is the third value (index 2) in the sequence returned frominspect.classify_class_attrs(object)
, which is defined as "The class which defined this attribute" (from the docstring). When the value of the class isobject
, the current if statementif thisclass is builtins.object:
results in that attribute being skipped from the output.The change is to skip the logic when the argument value is not builtins.object so that the attributes will be displayed when
help(object)
is used. Without this change, all of the attributes are skipped because "The class which defined this attribute" is alwaysobject
.