FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-135755: Docs: C API: Document missing `PyFunction_GET*` macros by ZeroIntensity · Pull Request #135762 · python/cpython · GitHub

/ cpython Public

gh-135755: Docs: C API: Document missing PyFunction_GET* macros - #135762

Merged
encukou merged 12 commits into
python:mainfrom
ZeroIntensity:document-function-macros
Jun 25, 2025
Merged

gh-135755: Docs: C API: Document missing PyFunction_GET* macros#135762
encukou merged 12 commits into
python:mainfrom
ZeroIntensity:document-function-macros

Conversation

ZeroIntensity commented Jun 20, 2025
edited
Loading

Copy link
Copy Markdown
Member

I'm documenting all of these before getting to PyFunction_GET_BUILTINS, because this needs to be backported to 3.13. I'll document PyFunction_GET_BUILTINS in a follow-up that goes only to 3.14.

I've included versionadded 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

ZeroIntensity requested a review from encukou June 20, 2025 14:51
ZeroIntensity added topic-C-API needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 20, 2025
bedevere-app Bot mentioned this pull request Jun 20, 2025
39 tasks
ZeroIntensity added docs Documentation in the Doc dir skip news labels Jun 20, 2025
github-project-automation Bot moved this to Todo in Docs PRs Jun 20, 2025
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>

picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Member

Looks good now:

encukou commented Jun 23, 2025
edited
Loading

Copy link
Copy Markdown
Member

Hm, that's a lot of repetition.
It might be easier for the reader -- and still semantically correct -- to put them all in a single block like this:

.. 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 versionadded:: for differences from 2.x; I don't think we should start now.
(What's controversial is whether we should remove versionadded:: 3.1 and such.)

Copy link
Copy Markdown
Member Author

Do we lose the reference count effect when we do that?

encukou commented Jun 23, 2025

Copy link
Copy Markdown
Member

Visually, it's at the end of the block. Together with the “equivalent to the respective functions” bit, I think it's enough.

Copy link
Copy Markdown
Member Author

Ok, I've updated it. Let me know what you think of the wording I chose.

Comment thread Doc/c-api/function.rst Outdated
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
Comment thread Doc/c-api/function.rst Outdated
encukou enabled auto-merge (squash) June 25, 2025 08:39

encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you!

encukou merged commit ca87a47 into python:main Jun 25, 2025
github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 25, 2025

Copy link
Copy Markdown

Thanks @ZeroIntensity for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 25, 2025
…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>

bedevere-app Bot commented Jun 25, 2025

Copy link
Copy Markdown

GH-135916 is a backport of this pull request to the 3.14 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 25, 2025
…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>
bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 25, 2025

bedevere-app Bot commented Jun 25, 2025

Copy link
Copy Markdown

GH-135917 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 25, 2025
encukou added a commit that referenced this pull request Jun 25, 2025
…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>
encukou added a commit that referenced this pull request Jun 25, 2025
…ros (GH-135762) (GH-135917)

(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>
ZeroIntensity deleted the document-function-macros branch June 25, 2025 11:31
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
…os (pythonGH-135762)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…os (pythonGH-135762)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…os (pythonGH-135762)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…os (pythonGH-135762)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news topic-C-API

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL