Skip to content

Return false when itemlists have different lengths - #36

Open
hakarrr wants to merge 2 commits into
gruns:masterfrom
hakarrr:fix-itemlist-equality-length
Open

hakarrr wants to merge 2 commits into
gruns:masterfrom
hakarrr:fix-itemlist-equality-length

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 24, 2026 •

Copy link
Copy Markdown

Comparing itemlists raises TypeError when either list is a strict prefix of the other, including empty versus nonempty lists. zip_longest supplies None for the exhausted iterator, but the loop unpacks it before it can return False.

Check for an exhausted operand before unpacking. The iterator yields triples, so real None keys and values remain valid. The regression covers both operand orders, == and !=, empty lists, shared prefixes, duplicate None entries, and unchanged contents. Controls cover equal lists and unequal keys, values, and order.

Validation:

  • Untouched master: 55 tests pass. With the new tests before the fix: 1 error, 56 pass.
  • With the fix: all 57 tests pass on CPython 3.9.25, 3.10.12, 3.11.17, and 3.12.15.
  • Python 3.12 coverage: 94% combined line/branch coverage; the new exhaustion guard is covered.
  • Changed-file flake8 and diff whitespace checks pass, excluding the existing W503 at itemlist.py:129. Wheel and sdist build pass.
  • Mypy retains the same pre-existing diagnostic at orderedmultidict.py:396, with no new diagnostics.

Python 2, older Python versions, PyPy, and other operating systems were not run. No existing tests were changed, and no CI configuration or unrelated behavior was changed.

@hakarrr

hakarrr commented Oct 29, 2026

Copy link
Copy Markdown
Author

Could you take a look at this itemlist prefix-comparison fix when you have time? It handles exhausted operands before unpacking while retaining valid None keys and values. The regression cases and local validation limits are recorded in the description; I am not claiming a hosted CI pass. Please let me know if any changes are needed for review. Thanks.

@hakarrr

hakarrr commented Nov 4, 2026

Copy link
Copy Markdown
Author

Hi, following up on this itemlist prefix-comparison fix. Would you have time to review it, or is there anything you'd like changed before review? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant