-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135755: Docs: C API: Document missing PyFunction_GET*
macros
#135762
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
Co-authored-by: Brian Schubert <[email protected]>
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'd appreciate if we have the "Return value: borrowed reference" for those functions (i.e., update refcounts.dat to add those entries).
Hm, that's a lot of repetition. .. c:function:: PyObject *PyFunction_GET_CODE(PyObject *op)
PyObject *PyFunction_GET_GLOBALS(PyObject *op)
PyObject *PyFunction_GET_MODULE(PyObject *op)
PyObject *PyFunction_GET_DEFAULTS(PyObject *op)
PyObject *PyFunction_GET_KW_DEFAULTS(PyObject *op)
PyObject *PyFunction_GET_CLOSURE(PyObject *op)
PyObject *PyFunction_GET_ANNOTATIONS(PyObject *op)
These macros are equivalent to the respective ``PyFunction_GetCode*``
functions documented above, except they do no type checking.
That is, if *op* is not of type :c:data:`PyFunction_Type`, the behavior
is undefined. We don't use |
Do we lose the reference count effect when we do that? |
Visually, it's at the end of the block. Together with the “equivalent to the respective functions” bit, I think it's enough. |
Ok, I've updated it. Let me know what you think of the wording I chose. |
Co-authored-by: Brian Schubert <[email protected]>
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.
Thank you!
Thanks @ZeroIntensity for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…os (pythonGH-135762) (cherry picked from commit ca87a47) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Brian Schubert <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
GH-135916 is a backport of this pull request to the 3.14 branch. |
…os (pythonGH-135762) (cherry picked from commit ca87a47) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Brian Schubert <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
GH-135917 is a backport of this pull request to the 3.13 branch. |
…ros (GH-135762) (GH-135916) gh-135755: Docs: C API: Document missing `PyFunction_GET*` macros (GH-135762) (cherry picked from commit ca87a47) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Brian Schubert <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
…ros (GH-135762) (GH-135917) (cherry picked from commit ca87a47) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Brian Schubert <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
I'm documenting all of these before getting to
PyFunction_GET_BUILTINS
, because this needs to be backported to 3.13. I'll documentPyFunction_GET_BUILTINS
in a follow-up that goes only to 3.14.I've includedversionadded
directives for a few APIs that were added in 3.0 (PEP-3102 and PEP-3107), but I don't know if those are particularly useful these days. AFAIK, it's a controversial topic.📚 Documentation preview 📚: https://cpython-previews--135762.org.readthedocs.build/en/135762/c-api/function.html#function-objects