Skip to content

bpo-44263: Better explain the GC contract for PyType_FromSpecWithBases #26442

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
May 29, 2021

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented May 29, 2021

@bedevere-bot bedevere-bot added awaiting core review docs Documentation in the Doc dir labels May 29, 2021
@pablogsal pablogsal requested review from encukou and vstinner and removed request for encukou May 29, 2021 00:01
@pablogsal pablogsal added skip news needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels May 29, 2021
@pablogsal
Copy link
Member Author

CC: @erlend-aasland

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

Thanks for the clarifications. I was pretty confused with your fix at 8b4312b. So I'm glad the reason is in the docs now!

If I'm understanding correctly, in that specific case, you want _ssl.SSLError to inherit its tp_traverse etc. fields from the parent PyExc_OSError (which implements the GC), so you didn't set Py_TPFLAGS_HAVE_GC in _ssl.SSLError?

@pablogsal
Copy link
Member Author

If I'm understanding correctly, in that specific case, you want _ssl.SSLError to inherit its tp_traverse etc. fields from the parent PyExc_OSError (which implements the GC), so you didn't set Py_TPFLAGS_HAVE_GC in _ssl.SSLError?

Correct, this is because SSLError doesn't add any extra fields: is just PyOSErrorObject.

@pablogsal pablogsal merged commit 8b55bc3 into python:main May 29, 2021
@pablogsal pablogsal deleted the gc_docs branch May 29, 2021 02:57
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

GH-26443 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label May 29, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 29, 2021
pythonGH-26442)

(cherry picked from commit 8b55bc3)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label May 29, 2021
@bedevere-bot
Copy link

GH-26444 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 29, 2021
pythonGH-26442)

(cherry picked from commit 8b55bc3)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
miss-islington added a commit that referenced this pull request May 29, 2021
GH-26442)

(cherry picked from commit 8b55bc3)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
pablogsal added a commit that referenced this pull request May 29, 2021
GH-26442) (GH-26443)

(cherry picked from commit 8b55bc3)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@encukou
Copy link
Member

encukou commented Jun 1, 2021

Thank you for the clarification!

@vstinner
Copy link
Member

vstinner commented Jun 1, 2021

Thank you for the clarification!

Yeah, thanks Pablo! This part wasn't obvious to me at all, especially the type inheritance part.

FYI Pablo and me hit this issue the hard way while debugging a random crash involving the _ssl.SSLError exception: https://bugs.python.org/issue44252 Two unit tests only crashed on Windows, and only if you ran the unit test in a very specific way. GC collections are not really "determistic" from my human debugger pointer of view :-) I made the crash more likely by running import gc; gc.set_threshold(5) at Python startup.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants