Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL)#143508
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Doc/c-api/intro.rst Outdated
| PyAPI_DATA(PyObject *) _Py_NoneStruct; | ||
| .. c:macro:: Py_LOCAL_SYMBOL |
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.
Could you move this next to the otherPy_LOCAL macros, and ideally match their style?
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 guessPy_ALWAYS_INLINE,Py_DEPRECATED,Py_LOCAL,Py_LOCAL_INLINE, all of these, and possiblyPy_UNUSED, could be moved to a new section. But that can be in a new PR.
Uh oh!
There was an error while loading.Please reload this page.
Doc/c-api/intro.rst Outdated
| .. c:macro:: Py_EXPORTED_SYMBOL | ||
| Macro used to declare a symbol (function or data) as exported from a shared library. | ||
| On Windows, this expands to ``__declspec(dllexport)``. | ||
| On other platforms with visibility support, it | ||
| expands to ``__attribute__((visibility("default")))``. | ||
| .. c:macro:: Py_IMPORTED_SYMBOL | ||
| Macro used to declare a symbol as imported from a shared library. | ||
| On Windows, this expands to ``__declspec(dllimport)``. | ||
| On other platforms, it is usually empty or standard visibility. |
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.
“from a shared library” is not true: these depend on whetherCPython's own C API is provided as a shared library.
The docs should say that these are for defining the C API itself; users shouldn't use them for their own symbols.
Yashp002 commentedJan 7, 2026
@encukou I think I've done all the necessary changes you asked for, could you verify it. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Doc/c-api/intro.rst Outdated
| Macro used to declare a public global variable. | ||
| It expands to ``extern Py_EXPORTED_SYMBOL type`` or ``extern Py_IMPORTED_SYMBOL type`` | ||
| depending on whether the core is being built or used. |
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 would also add:
"This macro is intended for defining CPython's C API itself; extension modules should not use it for their own symbols."
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.
gonna push a PR for the manual changes in a bit yes, thank you for the corrections
Co-authored-by: Victor Stinner <vstinner@python.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.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
a7ba3b1 intopython:mainUh oh!
There was an error while loading.Please reload this page.
GH-143786 is a backport of this pull request to the3.14 branch. |
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508)(cherry picked from commita7ba3b1)Co-authored-by: Yashraj <yashrajpala8@gmail.com>Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Victor Stinner <vstinner@python.org>
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508)(cherry picked from commita7ba3b1)Co-authored-by: Yashraj <yashrajpala8@gmail.com>Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Victor Stinner <vstinner@python.org>
GH-143787 is a backport of this pull request to the3.13 branch. |
Uh oh!
There was an error while loading.Please reload this page.
This PR documents several symbol visibility macros that were identified as undocumented in issue#141004. These macros are defined in
Include/exports.hand are used to control symbol visibility and linkage (dllexport/dllimport) across platforms.Macros documented in
Doc/c-api/intro.rst:Py_EXPORTED_SYMBOLPy_IMPORTED_SYMBOLPy_LOCAL_SYMBOLPyAPI_DATA📚 Documentation preview 📚:https://cpython-previews--143508.org.readthedocs.build/