summaryrefslogtreecommitdiffstats
path: root/Python/import.c
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 /Python/import.c
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 'Python/import.c')
-rw-r--r--Python/import.c3
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) {