-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 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 something must 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 do
this 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
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-141159) (cherry picked from commit ffd6473) 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 the 3.14 branch. |
|
Sorry, @encukou, I could not cleanly backport this to |
…tions (pythonGH-141159) (cherry picked from commit ffd6473) 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 the 3.13 branch. |
|
Thanks! Eventually we'll remove the requirement anyway :) |
…ythonGH-141159) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
When working on PEP-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/