Allow multiphase modules to be re-imported (#5782)

* Failing unit test

* Potential fix for the issue of re-importing a multi-phase module

- When a module is successfully imported and exec'd, save its handle in a dict in the interpreter state
- Use a special Py_mod_create slot to look in the cache and return the cached handle if it is in the cache
- Don't re-run the user exec function if the module is in the interpreter's cache (implying it was already successfully imported)

* Oops, need to inline these.

* Clang-Tidy fixes

* Oops, debug code

* Add xfail for this GraalPy bug

* Remove static from these function defs, it was a cut-and-paste error in the first place.

* Fix test comment

* Proper error handling

* Oops

* Split up this line, but still just ignore failure .. if the module doesn't have the right properties to check the cache then just allow exec to run.

* Clean up - already looked up the name, just use that.

* Some compilers complain if the pointer isn't taken here, weird.

* Allow attribute errors to be thrown here, will be converted to import errors by the exception handler.

* Remove bogus incref, unconditionally expect a __spec__.name on the module

* Add PR to test comment

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3 files changed