Skip to content

Preserve all values in OrderedMultiDict self-extension - #605

Closed
Gabrieljr42 wants to merge 1 commit into
mahmoud:masterfrom
Gabrieljr42:fix/omd-self-update-extend
Closed

Gabrieljr42 wants to merge 1 commit into
mahmoud:masterfrom
Gabrieljr42:fix/omd-self-update-extend

Conversation

@Gabrieljr42

Copy link
Copy Markdown

The change

OrderedMultiDict.update_extend() appends every value when its source is another multimap, but self-update only appends each key's latest value. Snapshot items(multi=True) in the self case so repeated values and their insertion order are preserved without iterating a changing linked list.

For example, self-updating [('a', 1), ('b', 2), ('a', 3)] now appends that full sequence, rather than just [('a', 3), ('b', 2)].

The regression fails on the original source. Validation: 681 tests and module doctests pass with tox -e py314; 33 dictionary tests also pass in a separate verification run. Python 3.14 reports five deprecation warnings.

The backstory

This is a first contribution to boltons, prepared with Codex in response to the contributor's request to find five more small open-source fixes. Comparing self-updates with updates from a separate multimap exposed the difference. It was found through source inspection and a local reproduction, rather than production use of the library.

AI assistance

  • Harness/tooling: OpenAI Codex desktop, Git, pytest and tox.
  • Models: GPT-6 parent review and a GPT-6-Luna implementation agent.
  • Codex investigated, implemented and tested the change. The parent independently reviewed the diff and reran the dictionary tests.
  • Original user direction: “Get 5 more lilely to be approved and merged (fast as possible). ANd run a sub agent luna from each one, and fix it”, followed by authorization for this additional batch: “yeah, go ahad”.
Implementation-agent prompts

Please find and fix ONE distinct, unreported concrete bug in boltons public utilities. Existing issue queues are saturated with competing PRs; a reproducible new defect can go straight to a PR, no issue filing needed. Inspect current public behaviors such as dictutils.OrderedMultiDict/ManyToMany, setutils.IndexedSet, iterutils helpers, fileutils, URL handling. Prefer ordinary inputs and documented guarantees; avoid contrived malicious objects or speculative APIs. Load open PR titles via direct GitHub listing. Report candidate reproduction and proposed scope before editing, then implement minimal fix with regression and required tests after root confirms.

Confirmed: update_extend(self) losing earlier values violates the documented multivalue append behavior. Proceed with a minimal self-case snapshot and regressions covering repeated keys, original order, empty self-update, and a non-self source as a control. Check frozen/proxy concerns only if relevant to this class. Tests should fail on the original source and pass with the fix.

mahmoud added a commit that referenced this pull request Oct 25, 2026
@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

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

@mahmoud mahmoud closed this Oct 25, 2026
blebo pushed a commit to blebo/boltons that referenced this pull request Nov 1, 2026
…d#605)

Workstream-Session-Id: 01a1743e-7af6-7000-999f-e3695b3279ef
Workstream-Plan-Id: 2026-10-25-7167a83d96
blebo pushed a commit to blebo/boltons that referenced this pull request Nov 1, 2026
…hmoud#608 to 26.3.0

Workstream-Session-Id: 01a1743e-7af6-7000-999f-e3695b3279ef
Workstream-Plan-Id: 2026-10-25-7167a83d96
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