gh-141536: Fix a crash when running test_capi *after* test_code in the same process
- Issue: gh-141536
There's CI problem with test_import for UBSan build. I have two sequential problems on my PR: https://github.com/python/cpython/pull/139717
See also https://github.com/python/cpython/issues/141545, https://github.com/python/cpython/issues/131229
Thanks @Yhg1s for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. 🐍🍒⛏🤖
Sorry, @Yhg1s, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b2827de18fe88152dc38c1aa76c39b69ef59cb6f 3.13
GH-143522 is a backport of this pull request to the 3.14 branch.
GH-143625 is a backport of this pull request to the 3.13 branch.