gh-138045: Fix importing numpy in legacy subinterpreters by skipping switch to main interpreter when not needed
(singlephase == NULL) check in update_global_state_for_extension could be removed because it's only called with pointers to stack objects.
I've tried creating a minimal working reproducer instead of importing numpy with the example from https://github.com/python/cpython/issues/138045#issuecomment-3216214055 but didn't manage to integrate that into Python's test suite. Maybe someone else has more knowledge on how to create a simple test that reproduce the numpy situation.
The fix can be backported down to 3.13.
- Issue: gh-138045
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.
If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.
Added a news entry. I was not able to implement a test, I already looked at _testsinglephase but wasn't able to setup something similar to numpy :(