Skip to content

Distinguish trailing None entries in OrderedMultiDict equality - #599

Closed
FanWu-ai wants to merge 1 commit into
mahmoud:masterfrom
FanWu-ai:fix/multidict-equality-padding-oct22
Closed

FanWu-ai wants to merge 1 commit into
mahmoud:masterfrom
FanWu-ai:fix/multidict-equality-padding-oct22

Conversation

@FanWu-ai

Copy link
Copy Markdown

The change

Fix false equality between OrderedMultiDict instances that have different numbers of trailing (None, None) entries. OMD([(None, None)]) == OMD([(None, None), (None, None)]) currently returns True: len counts distinct keys, and the subsequent zip_longest uses a real (None, None) pair as padding. The post-loop exhaustion check cannot distinguish these lengths because zip_longest has consumed both iterators.

Use the existing private sentinel as padding and detect exhaustion before unpacking each pair. Apply the same fix to the embedded OrderedMultiDict implementation in urlutils. Tests cover both comparison directions, repeated trailing entries, equal controls, FastIterOrderedMultiDict and QueryParamDict.

Validation on Python 3.12.14:

  • Project-prescribed built-package full suite and doctests, tox -e py312: baseline 678 passed; fixed 681 passed.
  • New regression cases on the original implementation: 3 failed.
  • git diff --check: passed.

Searched existing issues and PRs for equality, OrderedMultiDict and zip_longest. #404 fixes comparison to plain mappings and #420 proposes query parameter ordering semantics; neither addresses this exhaustion collision.

The backstory

Previous contribution: #571. This issue was found during a review of the multimap's equality comparison, not from a production incident.

AI assistance

  • Harness/tooling: OpenAI Codex assistance, Git, uv, pytest and tox.
  • Model(s): OpenAI model; exact serving model identifier is not exposed to this task.
  • Original prompt: “为我执行 GitHub 高星开源项目 bug 修复,目标每批10个真实、独立且有价值的 bug。项目至少 5000 星,优先 10000 星以上;优先 Python 和当前环境能充分验证的项目。先检查环境、原版完整测试、贡献要求及 AI 使用政策,排除重复修复和已有 PR,随后复现、修复并补回归测试。实际执行修复,不只提供候选清单。遵循执行时生效的用户指示、权限和 Custom rules 决定提交及审查操作,不把此任务当作额外权限。不降低测试标准,不拆小改动凑数,不绕过限制。接续未完成工作并记录当批进展,避免重叠任务或重复提交。完成后在本 ChatGPT 对话简要汇报实际完成数量、核实的 PR 链接、测试与线上检查状态;未达10个如实说明原因,不承诺合并。仅在需要用户处理的关键阻碍出现时提前提醒。”

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 21, 2026 22:20
@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Folded into #609 (see the PR description for credit). Thanks for the report and the repro.

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.

2 participants