-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-44301: Docs: Note that tp_clear and m_clear are not always called #27581
Conversation
I still intend to write some better tutorial-style docs on supporting GC. For the reference docs, I think this quick note is useful enough. |
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.
LGTM
A common pattern thought is to invoke tp_clear in tp_dealloc
That's mentioned in the paragraph below (for types; for modules there's a link to |
(cherry picked from commit 10faada) Co-authored-by: Petr Viktorin <encukou@gmail.com>
GH-27596 is a backport of this pull request to the 3.10 branch. |
(cherry picked from commit 10faada) Co-authored-by: Petr Viktorin <encukou@gmail.com>
GH-27597 is a backport of this pull request to the 3.9 branch. |
(cherry picked from commit 10faada) Co-authored-by: Petr Viktorin <encukou@gmail.com>
Thanks @encukou, implementing a type in C is complex, and better documentation is very valuable! |
It was not clear from the documentation that
tp_clear
(or in this case,m_clear
of modules) is only called by the cyclic GC; when the object reaches zero refcount,tp_clear
isn't called.https://bugs.python.org/issue44301