Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
encukou merged 11 commits intopython:mainfromYashp002:doc-exports
Jan 13, 2026

Conversation

@Yashp002
Copy link
Contributor

@Yashp002Yashp002 commentedJan 7, 2026
edited by github-actionsbot
Loading

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

Macros documented inDoc/c-api/intro.rst:

  • Py_EXPORTED_SYMBOL
  • Py_IMPORTED_SYMBOL
  • Py_LOCAL_SYMBOL
  • PyAPI_DATA

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

PyAPI_DATA(PyObject *) _Py_NoneStruct;


.. c:macro:: Py_LOCAL_SYMBOL
Copy link
Member

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?

Copy link
Member

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.

ZeroIntensity reacted with thumbs up emoji
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
Member

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.

@ZeroIntensityZeroIntensity added topic-C-API needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsJan 7, 2026
@Yashp002
Copy link
ContributorAuthor

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

Yashp002and others added4 commitsJanuary 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>

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
Member

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

Copy link
ContributorAuthor

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

Yashp002and others added2 commitsJanuary 8, 2026 23:01
Co-authored-by: Victor Stinner <vstinner@python.org>
Yashp002and others added2 commitsJanuary 9, 2026 16:43
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
@encukouencukou merged commita7ba3b1 intopython:mainJan 13, 2026
55 checks passed
@github-project-automationgithub-project-automationbot moved this fromTodo toDone inDocs PRsJan 13, 2026
@miss-islington-app
Copy link

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

Yashp002 reacted with heart emoji

@bedevere-app
Copy link

GH-143786 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJan 13, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 13, 2026
…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>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 13, 2026
…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>
@bedevere-app
Copy link

GH-143787 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJan 13, 2026
encukou added a commit that referenced this pull requestJan 15, 2026
…XPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (GH-143508) (GH-143786)(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>
encukou added a commit that referenced this pull requestJan 15, 2026
…XPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (GH-143508) (GH-143787)(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>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner left review comments

@encukouencukouencukou left review comments

@ZeroIntensityZeroIntensityAwaiting requested review from ZeroIntensityZeroIntensity is a code owner

Assignees

No one assigned

Labels

docsDocumentation in the Doc dirskip newstopic-C-API

Projects

Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Yashp002@vstinner@encukou@ZeroIntensity

[8]ページ先頭

©2009-2026 Movatter.jp