FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) by Yashp002 · Pull Request #143508 · python/cpython · GitHub

/ cpython Public

gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) - #143508

Merged
encukou merged 11 commits into
python:mainfrom
Yashp002:doc-exports
Jan 13, 2026
Merged

gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL)#143508
encukou merged 11 commits into
python:mainfrom
Yashp002:doc-exports

Conversation

Yashp002 commented Jan 7, 2026
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Contributor

This PR documents several symbol visibility macros that were identified as undocumented in issue #141004. These macros are defined in Include/exports.h and are used to control symbol visibility and linkage (dllexport/dllimport) across platforms.

Macros documented in Doc/c-api/intro.rst:

  • Py_EXPORTED_SYMBOL
  • Py_IMPORTED_SYMBOL
  • Py_LOCAL_SYMBOL
  • PyAPI_DATA

📚 Documentation preview 📚: https://cpython-previews--143508.org.readthedocs.build/

bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jan 7, 2026
github-project-automation Bot moved this to Todo in Docs PRs Jan 7, 2026
Comment thread Doc/c-api/intro.rst Outdated
PyAPI_DATA(PyObject *) _Py_NoneStruct;


.. c:macro:: Py_LOCAL_SYMBOL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could you move this next to the other Py_LOCAL macros, and ideally match their style?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess Py_ALWAYS_INLINE, Py_DEPRECATED, Py_LOCAL, Py_LOCAL_INLINE, all of these, and possibly Py_UNUSED, could be moved to a new section. But that can be in a new PR.

Comment thread Doc/c-api/intro.rst
Comment thread Doc/c-api/intro.rst Outdated
Comment on lines +379 to +391
.. 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

“from a shared library” is not true: these depend on whether CPython'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.

ZeroIntensity added topic-C-API needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jan 7, 2026

Yashp002 commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

@encukou I think I've done all the necessary changes you asked for, could you verify it.

Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst
Comment thread Doc/c-api/intro.rst Outdated
Yashp002 and others added 4 commits January 8, 2026 22:42
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>
Comment thread 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

gonna push a PR for the manual changes in a bit yes, thank you for the corrections

Yashp002 and others added 2 commits January 8, 2026 23:01
Co-authored-by: Victor Stinner <vstinner@python.org>
Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
Yashp002 and others added 2 commits January 9, 2026 16:43
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
encukou merged commit a7ba3b1 into python:main Jan 13, 2026
55 checks passed
github-project-automation Bot moved this from Todo to Done in Docs PRs Jan 13, 2026

Copy link
Copy Markdown

Thanks @Yashp002 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

bedevere-app Bot commented Jan 13, 2026

Copy link
Copy Markdown

GH-143786 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jan 13, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2026
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508)

(cherry picked from commit a7ba3b1)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2026
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508)

(cherry picked from commit a7ba3b1)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>

bedevere-app Bot commented Jan 13, 2026

Copy link
Copy Markdown

GH-143787 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jan 13, 2026
encukou added a commit that referenced this pull request Jan 15, 2026
…XPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (GH-143508) (GH-143786)

(cherry picked from commit a7ba3b1)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
encukou added a commit that referenced this pull request Jan 15, 2026
…XPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (GH-143508) (GH-143787)

(cherry picked from commit a7ba3b1)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news topic-C-API

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL