Uh oh!
There was an error while loading. Please reload this page.
gh-91118: Fix docstrings that do not honor --without-doc-strings - #31769
Conversation
JelleZijlstra
left a comment
There was a problem hiding this comment.
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.
| :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.
| :class:`~_ctypes.PyCStructType:. | |
| :class:`~_ctypes.PyCStructType`. |
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…IVe9I.rst Co-authored-by: Éric <merwok@netwok.org>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
miss-islington
commented
Apr 18, 2022
Thanks @arhadthedev for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
miss-islington
commented
Apr 18, 2022
Thanks @arhadthedev for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
miss-islington
commented
Apr 18, 2022
Sorry, @arhadthedev and @JelleZijlstra, I could not cleanly backport this to |
miss-islington
commented
Apr 18, 2022
Sorry @arhadthedev and @JelleZijlstra, I had trouble checking out the |
JelleZijlstra
commented
Apr 18, 2022
@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>
bedevere-bot
commented
Apr 18, 2022
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)
bedevere-bot
commented
Apr 18, 2022
GH-91663 is a backport of this pull request to the 3.9 branch. |
arhadthedev
commented
Apr 18, 2022
That backport to 3.9 was targeted to main instead of 3.9. The new, correct entry is GH-91664. |
…strings (pythonGH-31769) (python#91664) Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit a573cb2)
To support
--without-doc-strings, all docstrings must be wrapped intoPyDoc_STRVARorPyDoc_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*".FixesGH-91118.