Uh oh!
There was an error while loading. Please reload this page.
gh-135755: Docs: C API: Document missing PyFunction_GET* macros - #135762
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
picnixz
left a comment
There was a problem hiding this comment.
I'd appreciate if we have the "Return value: borrowed reference" for those functions (i.e., update refcounts.dat to add those entries).
picnixz
commented
Jun 20, 2025
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 |
ZeroIntensity
commented
Jun 23, 2025
Do we lose the reference count effect when we do that? |
encukou
commented
Jun 23, 2025
Visually, it's at the end of the block. Together with the “equivalent to the respective functions” bit, I think it's enough. |
ZeroIntensity
commented
Jun 23, 2025
Ok, I've updated it. Let me know what you think of the wording I chose. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 <zintensitydev@gmail.com> Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
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 <zintensitydev@gmail.com> Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
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 <zintensitydev@gmail.com> Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
…os (pythonGH-135762) Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
…os (pythonGH-135762) Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
…os (pythonGH-135762) Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
…os (pythonGH-135762) Co-authored-by: Brian Schubert <brianm.schubert@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>

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_BUILTINSin a follow-up that goes only to 3.14.I've includedversionaddeddirectives 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