-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-107298: Document PyAPI_DATA() macro #109129
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
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.
I saw these Sphinx warnings on a PR which doesn't touch |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
Are PyAPI_FUNC()
and PyAPI_DATA()
purposed to be used in a third-party code at all?
I wrote "The macro should only be used in Python C API." They should not be used outside Python code base. |
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? |
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! |
I would be fine with that as well. |
Ok, I created the opposite change: PR #109236 removes links to these 3 macros. |
@serhiy-storchaka Which do you prefer? |
(I prefer to not document them, PR #109236.) |
Sounds good to me. |
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/