[3.13] gh-120782: Update internal type cache when reloading datetime (GH-120829) by neonene · Pull Request #120855 · python/cpython
When reloading _datetime module, the single-phase version did not invoke the PyInit__datetime function, whereas the current multi-phase version updates the static types through the module init. The outdated static type cache in the interpreter state needs to be invalidated at the end of reloading the multi-phase module.
This PR is a manual backport of a81d434, adding assert statements to the test case.
This also backports e6076d1 (gh-120180) manually.