summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-27 19:11:29 (GMT)
committerGitHub <noreply@github.com>2024-05-27 19:11:29 (GMT)
commitbd9983cab89cc42eecdbb4556cca0b6d7a7c529c (patch)
tree3a93e60e20dce025da387b100bae243fb825eb2d /Lib
parent0a4a3184f56a1e4e8cb4d3466cee20388bf7f00d (diff)
downloadcpython-bd9983cab89cc42eecdbb4556cca0b6d7a7c529c.zip
cpython-bd9983cab89cc42eecdbb4556cca0b6d7a7c529c.tar.gz
cpython-bd9983cab89cc42eecdbb4556cca0b6d7a7c529c.tar.bz2
[3.13] gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561) (gh-119632)
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. (cherry picked from commit 0c5ebe13e9937c446e9947c44f2570737ecca135) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_import/__init__.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index 64282d0..11eaae5 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -2887,6 +2887,13 @@ class SinglephaseInitTests(unittest.TestCase):
self.assertIs(reloaded.snapshot.cached, reloaded.module)
+ def test_check_state_first(self):
+ for variant in ['', '_with_reinit', '_with_state']:
+ name = f'{self.NAME}{variant}_check_cache_first'
+ with self.subTest(name):
+ mod = self._load_dynamic(name, self.ORIGIN)
+ self.assertEqual(mod.__name__, name)
+
# Currently, for every single-phrase init module loaded
# in multiple interpreters, those interpreters share a
# PyModuleDef for that object, which can be a problem.