Skip to content

gh-160840: In PyType_GetModuleByToken, fall back to tp_bases if tp_mro is gone - #162160

Open
encukou wants to merge 1 commit into
python:mainfrom
encukou:getmodulelebydef-safe
Open

encukou wants to merge 1 commit into
python:mainfrom
encukou:getmodulelebydef-safe

Conversation

@encukou

@encukou encukou commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

PyType_GetModuleByToken asserted that a type's mro is not NULL, but this can happen when cleaning a GC cycle. If it does, we can still fall back to walking tp_bases.

@da-woods, could you check if this solves the issue for Cython?

… tp_mro is gone

`PyType_GetModuleByToken` asserted that a type's `mro` is not NULL,
but this can happen when cleaning a GC cycle. If it does, we can
still fall back to walking `tp_bases`.
@da-woods

Copy link
Copy Markdown
Contributor

@da-woods, could you check if this solves the issue for Cython?

Yes I think so. This was something I found while working on some currently unmerged changes. But the test that was failing now seems to pass with this. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants