Uh oh!
There was an error while loading. Please reload this page.
gh-107298: Document PyAPI_DATA() macro - #109129
Conversation
Document PyAPI_DATA(), and PyAPI_FUNC() and PyMODINIT_FUNC macros in Doc/c-api/intro.rst. This change fix Sphinx warnings in Doc/using/configure.rst.
vstinner
commented
Sep 8, 2023
I saw these Sphinx warnings on a PR which doesn't touch |
hugovk
commented
Sep 8, 2023
Yep, all Sphinx warnings are logging during docs builds, regardless of whether you touch the actual file. For example, this PR has the remaining warnings for that file: |
| macro should only be used in Python C API. Example:: | ||
| PyAPI_DATA(const unsigned long) Py_Version; | ||
| .. c:macro:: PyAPI_FUNC(type) | ||
| Declare a function with a return type *type* which should be exported by | ||
| Python. The macro should only be used in Python C API. Example:: | ||
| PyAPI_FUNC(PyObject *) PyLong_FromLong(long); | ||
| .. c:macro:: PyMODINIT_FUNC | ||
| Declare an extension module ``PyInit`` initialization function. The return | ||
| type is :c:expr:`PyObject*`. The macro should only be used in Python C API. |
There was a problem hiding this comment.
Thanks! Little suggestion adding 3 x "the":
| macro should only be used in Python C API. Example:: | |
| PyAPI_DATA(const unsigned long) Py_Version; | |
| .. c:macro:: PyAPI_FUNC(type) | |
| Declare a function with a return type *type* which should be exported by | |
| Python. The macro should only be used in Python C API. Example:: | |
| PyAPI_FUNC(PyObject *) PyLong_FromLong(long); | |
| .. c:macro:: PyMODINIT_FUNC | |
| Declare an extension module ``PyInit`` initialization function. The return | |
| type is :c:expr:`PyObject*`. The macro should only be used in Python C API. | |
| macro should only be used in the Python C API. Example:: | |
| PyAPI_DATA(const unsigned long) Py_Version; | |
| .. c:macro:: PyAPI_FUNC(type) | |
| Declare a function with a return type *type* which should be exported by | |
| Python. The macro should only be used in the Python C API. Example:: | |
| PyAPI_FUNC(PyObject *) PyLong_FromLong(long); | |
| .. c:macro:: PyMODINIT_FUNC | |
| Declare an extension module ``PyInit`` initialization function. The return | |
| type is :c:expr:`PyObject*`. The macro should only be used in the Python C API. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Are PyAPI_FUNC() and PyAPI_DATA() purposed to be used in a third-party code at all?
vstinner
commented
Sep 8, 2023
I wrote "The macro should only be used in Python C API." They should not be used outside Python code base. |
hugovk
commented
Sep 8, 2023
Then should we explicitly document them as "internal"? Or not document at all and silence the warnings? Which leads to a third question: why are other docs referring to internal things? |
vstinner
commented
Sep 8, 2023
There is no clear separation between public and internal APIs in the documentation. But the internal API is almost not documented at all. So far, I only saw 2 functions: _PyBytes_Resize() and _PyTuple_Resize(). Last years, I removed mentions of many private C API functions like _Py_NewReference() or PyImport_Cleanup(). I even removed PyImport_Cleanup() from the public C API (I made it internal) :-) I was surprised to see: https://docs.python.org/dev/library/test.html
One day, it was proposed to have a separated documentation for the internal APIs, but nobody proposed anything concrete. Sometimes I wish I could document these internal APIs, but I cannot, since their documentation has no home! |
vstinner
commented
Sep 8, 2023
I would be fine with that as well. |
vstinner
commented
Sep 10, 2023
Ok, I created the opposite change: PR #109236 removes links to these 3 macros. |
hugovk
commented
Sep 11, 2023
@serhiy-storchaka Which do you prefer? |
vstinner
commented
Sep 11, 2023
(I prefer to not document them, PR #109236.) |
hugovk
commented
Sep 11, 2023
Sounds good to me. |
vstinner
commented
Sep 11, 2023
I close this PR, let's continue the discussion in PR #109236. |
Document PyAPI_DATA(), and PyAPI_FUNC() and PyMODINIT_FUNC macros in Doc/c-api/intro.rst. This change fix Sphinx warnings in Doc/using/configure.rst.
📚 Documentation preview 📚: https://cpython-previews--109129.org.readthedocs.build/