diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2024-05-25 19:30:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-25 19:30:48 (GMT) |
commit | 0c5ebe13e9937c446e9947c44f2570737ecca135 (patch) | |
tree | 6498ee1ee5fdf54b6adccfb9af9c42a53d82c4c6 /Python | |
parent | 4b7eb321bc43e41371df86fce47bd999ee51a793 (diff) | |
download | cpython-0c5ebe13e9937c446e9947c44f2570737ecca135.zip cpython-0c5ebe13e9937c446e9947c44f2570737ecca135.tar.gz cpython-0c5ebe13e9937c446e9947c44f2570737ecca135.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index ba44477..4f3325a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -457,7 +457,6 @@ static Py_ssize_t _get_module_index_from_def(PyModuleDef *def) { Py_ssize_t index = def->m_base.m_index; - assert(index > 0); #ifndef NDEBUG struct extensions_cache_value *cached = _find_cached_def(def); assert(cached == NULL || index == _get_cached_module_index(cached)); @@ -489,7 +488,7 @@ _set_module_index(PyModuleDef *def, Py_ssize_t index) static const char * _modules_by_index_check(PyInterpreterState *interp, Py_ssize_t index) { - if (index == 0) { + if (index <= 0) { return "invalid module index"; } if (MODULES_BY_INDEX(interp) == NULL) { |