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
base:main
Are you sure you want to change the base?
Conversation
| ``'utf-8'``. | ||
| The returned buffer is only valid until the module is renamed or destroyed. | ||
| Note that Python code may rename a module by setting its ``__name__`` |
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.
This can be a link:
| Note that Python code may rename a module by setting its``__name__`` | |
| Note that Python code may rename a module by setting its:py:attr:`~module.__name__` |
| Similar to:c:func:`PyModule_GetFilenameObject` but return the filename | ||
| encoded to 'utf-8'. | ||
| The returned buffer is only valid until the module's ``__file__`` attribute |
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.
Same here; we might as well link where we can.
| The returned buffer is only valid until the module's``__file__`` attribute | |
| The returned buffer is only valid until the module's:py:attr:`~module.__file__` attribute |
| 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.
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/