Closed
Description
Example:
vstinner@mona$ ./python -m test test_import -R 3:3 -m test_check_state_first -v
(...)
test_check_state_first (test.test_import.SinglephaseInitTests.test_check_state_first) ...
python: ./Modules/_testsinglephase.c:714: PyInit__testsinglephase_with_reinit_check_cache_first: Assertion `_testsinglephase_with_reinit_check_cache_first.m_base.m_index == 0' failed.
Fatal Python error: Aborted
Current thread 0x00007f56b95a6740 (most recent call first):
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1316 in create_module
File "<frozen importlib._bootstrap>", line 813 in module_from_spec
File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
File "<frozen importlib._bootstrap>", line 966 in _load
File "/home/vstinner/python/main/Lib/test/test_import/__init__.py", line 2495 in _load_dynamic
File "/home/vstinner/python/main/Lib/test/test_import/__init__.py", line 2894 in test_check_state_first
(...)
Regression: commit 0c5ebe1
commit 0c5ebe13e9937c446e9947c44f2570737ecca135
Author: Eric Snow <ericsnowcurrently@gmail.com>
Date: Sat May 25 15:30:48 2024 -0400
gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)
The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def. I've added a test to make sure we don't make that assumption again.
@ericsnowcurrently: Can you please have a look?