Skip to content

gh-159739: Keep the instance type alive during ABC subclass checks - #160198

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-abc-instancecheck-type
Oct 22, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-abc-instancecheck-type

Conversation

@jelle-openai

@jelle-openai jelle-openai commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

When an instance advertises a __class__ different from its actual type, ABCMeta.__instancecheck__ performs two subclass checks. The first callback can change the instance's actual type and allow its old type to be collected before the second check, causing a crash. Keep the original type alive through both checks. Backport to 3.15 and 3.14.

When an instance advertises a __class__ different from its actual type, ABCMeta.__instancecheck__ performs two subclass checks. The first callback can change the instance's actual type and allow its old type to be collected before the second check, causing a crash. Keep the original type alive through both checks. Backport to 3.15 and 3.14.
@JelleZijlstra
JelleZijlstra merged commit dcbc453 into python:main Oct 22, 2026
58 checks passed
@JelleZijlstra JelleZijlstra added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 22, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @jelle-openai and @JelleZijlstra, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker dcbc45356ea7ccc8038f40dd293f0e338f5ff977 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @jelle-openai and @JelleZijlstra, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker dcbc45356ea7ccc8038f40dd293f0e338f5ff977 3.15

1 similar comment
@miss-islington-app

Copy link
Copy Markdown

Sorry, @jelle-openai and @JelleZijlstra, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker dcbc45356ea7ccc8038f40dd293f0e338f5ff977 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @jelle-openai and @JelleZijlstra, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker dcbc45356ea7ccc8038f40dd293f0e338f5ff977 3.14

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

Labels

needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants