Fix (ish) hanging tests in `test_list.py` by ShaharNaveh ¡ Pull Request #7382 ¡ RustPython/RustPython
Actionable comments posted: 3
đ¤ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/vm/src/builtins/list.rs`:
- Line 579: The code uses vm.bool_eq in the identity fast-path and later ignores
the requested comparator `op`; change the first-phase check to use
vm.identical_or_equal(zitem, oitem) instead of vm.bool_eq so
identical-but-unequal objects match the fast path, and in the second phase
replace the equality-only check with the proper comparator call (e.g.,
vm.bool_op(op, zitem, oitem) or the existing VM method that evaluates `op`) so
the ordered comparisons (using `op`) are honored; update the branches that
reference zitem, oitem and op accordingly.
- Around line 560-574: The comparison loop using zelements and oelements only
refreshes snapshots when lengths (zlen/olen) change, which allows in-place
mutations of elements to leave stale values; update the loop in the
equality/comparison routine (the block that uses zelf.borrow_vec(),
other.borrow_vec(), zelements, oelements, zlen, olen and the index i) so that
each iteration reads the current element(s) directly from the live lists (e.g.,
call zelf.borrow_vec() and other.borrow_vec() and index into them for the items
being compared) or otherwise refresh the snapshots for the specific indices
per-iteration instead of gating refreshes on length changes, ensuring
comparisons always use the current elements.
- Around line 565-577: The loop condition uses "while i < zlen || i < olen"
which allows indexing both snapshots when only one has an element; change it to
"while i < zlen && i < olen" so the prefix scan only runs while both zelements
and oelements have an index i; adjust no other logic â keep the existing refetch
of zelements/oelements and the subsequent size-based fallback unchanged
(identify zelements, oelements, zlen, olen, and i in the loop to locate the
change).
âšī¸ Review info
âī¸ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 6450e6c7-fcd0-4701-8cf8-bf43b2a67dc5
â Files ignored due to path filters (1)
Lib/test/test_list.pyis excluded by!Lib/**
đ Files selected for processing (1)
crates/vm/src/builtins/list.rs