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-91118: Fix docstrings that do not honor --without-doc-strings #31769
gh-91118: Fix docstrings that do not honor --without-doc-strings #31769
Conversation
There are a bunch of others, mostly in ctypes:
% git grep '".*tp_doc\s*'
Doc/c-api/typeobj.rst: "My objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "deletes a key from a dictionary", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for the CData Objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for the CData Objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for the Pointer Objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for the Array Objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for the PyCSimpleType Objects", /* tp_doc */
Modules/_ctypes/_ctypes.c: "metatype for C function pointers", /* tp_doc */
Modules/_ctypes/_ctypes.c: "XXX to be provided", /* tp_doc */
Modules/_ctypes/_ctypes.c: "Function Pointer", /* tp_doc */
Modules/_ctypes/_ctypes.c: "Structure base class", /* tp_doc */
Modules/_ctypes/_ctypes.c: "Union base class", /* tp_doc */
Modules/_ctypes/_ctypes.c: "XXX to be provided", /* tp_doc */
Modules/_ctypes/_ctypes.c: "XXX to be provided", /* tp_doc */
Modules/_ctypes/_ctypes.c: "XXX to be provided", /* tp_doc */
Modules/_ctypes/callbacks.c: "CThunkObject", /* tp_doc */
Modules/_ctypes/cfield.c: "Structure/Union member", /* tp_doc */
Modules/_testcapimodule.c: "Instantiating this exception starts infinite recursion.", /* tp_doc */
I'm a bit skeptical about how useful this is, though—does anyone actually use the configure option to strip docstrings?
:func:`ctypes.CopyComPointer`, :func:`ctypes.FormatError`, | ||
:func:`ctypes.FreeLibrary`, :func:`ctypes.LoadLibrary`, and | ||
:func:`ctypes.sizeof`, along with a bunch of methods in | ||
:class:`~_ctypes.PyCPointerType:, :class:`~_ctypes.PyCSimpleType:, and |
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.
:class:`~_ctypes.PyCPointerType:, :class:`~_ctypes.PyCSimpleType:, and | |
:class:`~_ctypes.PyCPointerType`, :class:`~_ctypes.PyCSimpleType`, and |
:func:`ctypes.FreeLibrary`, :func:`ctypes.LoadLibrary`, and | ||
:func:`ctypes.sizeof`, along with a bunch of methods in | ||
:class:`~_ctypes.PyCPointerType:, :class:`~_ctypes.PyCSimpleType:, and | ||
:class:`~_ctypes.PyCStructType:. |
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.
:class:`~_ctypes.PyCStructType:. | |
:class:`~_ctypes.PyCStructType`. |
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.
I'm a bit skeptical about how useful this is, though—does anyone actually use the configure option to strip docstrings?
I think that if a flag exists, it should work fully. Also it's enabled by default so strings that should not be in the binary are no longer there.
Misc/NEWS.d/next/Core and Builtins/2022-03-08-21-59-57.bpo-46962.UomDfz.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Documentation/2022-03-08-22-10-38.bpo-46962.FIVe9I.rst
Outdated
Show resolved
Hide resolved
…IVe9I.rst Co-authored-by: Éric <merwok@netwok.org>
Misc/NEWS.d/next/Core and Builtins/2022-03-08-21-59-57.bpo-46962.UomDfz.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Core and Builtins/2022-03-08-21-59-57.bpo-46962.UomDfz.rst
Outdated
Show resolved
Hide resolved
Thanks @arhadthedev for the PR, and @JelleZijlstra for merging it |
Thanks @arhadthedev for the PR, and @JelleZijlstra for merging it |
Sorry, @arhadthedev and @JelleZijlstra, I could not cleanly backport this to |
Sorry @arhadthedev and @JelleZijlstra, I had trouble checking out the |
@arhadthedev do you want to do the backports? I feel like the docs changes are most important to backport. |
…-strings (pythonGH-31769) Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit a573cb2) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
GH-91662 is a backport of this pull request to the 3.10 branch. |
python#31769) Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit a573cb2)
GH-91663 is a backport of this pull request to the 3.9 branch. |
That backport to 3.9 was targeted to main instead of 3.9. The new, correct entry is GH-91664. |
To support
--without-doc-strings
, all docstrings must be wrapped intoPyDoc_STRVAR
orPyDoc_STR
(PEP 7). However, there are 18 occurrences in code and 10 in C API documentation that do not follow this rule. The documentation is important too because it should not teach people the wrong things.To find the occurrences I searched for
(?:^\s*.tp_doc = "|" \/\* tp_doc \*\/$)
and^(?:static\s+)?const\s+char\s+[^=]+=\s*"
.Fixes GH-91118.