Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Clarify argument/result ownership/validity for PyModule_* functions#141159
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
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| The *functions* array must be statically allocated (or otherwise guaranteed | ||
| to outlive the module object). |
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 think it's a little bit confusing to say somethingmust be true, and then immediately contradict it. How about we say something like this?
The *functions* array must outlive the module object. A common way to dothis is to statically allocate it.| The *functions* array must be statically allocated (or otherwise guaranteed | ||
| to outlive the module object). |
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 don't think there is a practical alternative unless you're doing something really special, so I would like keep this footnote-ish -- but part of the same sentence to avoid wording like “as a special exception”.
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.
Ok, I don't wholly agree, but I won't bother arguing about it.
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
ZeroIntensity left a comment
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.
LGTM
ffd6473 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-141159)(cherry picked from commitffd6473)Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
GH-141190 is a backport of this pull request to the3.14 branch. |
Sorry,@encukou, I could not cleanly backport this to |
…tions (pythonGH-141159)(cherry picked from commitffd6473)Co-authored-by: Petr Viktorin <encukou@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
GH-141191 is a backport of this pull request to the3.13 branch. |
encukou commentedNov 7, 2025
Thanks! Eventually we'll remove the requirement anyway :) |
Uh oh!
There was an error while loading.Please reload this page.
When working onPEP-793 docs, I found some backportable clarifications. (Sure, some clarify that the functions are somewhat dangerous with free-threading...)
Also: Turn a mention of
types.ModuleTypeinto a link.📚 Documentation preview 📚:https://cpython-previews--141159.org.readthedocs.build/