Skip to content

Document that PyType_GetModuleByDef returns a borrowed reference #135666

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

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

encukou
Copy link
Member

@encukou encukou commented Jun 18, 2025

@@ -282,6 +282,10 @@ Type Objects
and other places where a method's defining class cannot be passed using the
:c:type:`PyCMethod` calling convention.
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
and will be valid as long as you hold a reference to *type*.
Do not release it with :c:func:`Py_DECREF` or similar.
Copy link
Contributor

@neonene neonene Jun 18, 2025

Choose a reason for hiding this comment

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

I prefer L287 to have "otherwise" or something if hold a reference implies a Py_INCREF() in the previous line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I completely misread that, mixing the module and the type. LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries. Thanks for checking!

@encukou encukou merged commit 140731f into python:main Jun 19, 2025
43 checks passed
@miss-islington-app
Copy link

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

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jun 19, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 19, 2025
…honGH-135666)

(cherry picked from commit 140731ff671395fb7a869c2784429c14dc83fb27)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 19, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jun 19, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 19, 2025
…honGH-135666)

(cherry picked from commit 140731f)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 19, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 19, 2025
@encukou encukou deleted the getmodule-borrowed branch June 19, 2025 07:17
encukou added a commit that referenced this pull request Jun 19, 2025
…ce (GH-135666) (GH-135701)

(cherry picked from commit 140731f)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
encukou added a commit that referenced this pull request Jun 19, 2025
…ce (GH-135666) (GH-135702)

(cherry picked from commit 140731f)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants