Repository navigation
Conversation
Snapshot self-extension before appending, while preserving streaming behavior for other iterables. Add bounded regression tests and compatibility controls. Assisted-by: OpenAI Codex
Owner
|
Folded into #609 (see the PR description for credit). Thanks for the report and the repro. |
blebo
pushed a commit
to blebo/boltons
that referenced
this pull request
Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The change
Make
BarrelList.extend(self)terminate with the same contents as a built-in list extended with itself. The current implementation passes the BarrelList's live iterator to its last underlying list; that iterator then consumes newly appended values and continues growing.Snapshot only when the iterable is the receiver itself. Other iterables retain the existing streaming behavior, including partial updates when an iterator raises. This does not change
extend(iter(value)), for which a built-in list also has a live-iterator hazard.The regression tests cap iteration at the original length so a failure cannot hang the test runner or exhaust its memory. They cover empty lists, single/multiple barrels, empty internal/tail barrels, object identity, other iterable types, and a failing iterator.
Validation on Windows / CPython 3.13.15:
extendmethod has 100% statement and branch coverage.git diff --checkpassed.Other Python versions and operating systems have not been run locally.
The backstory
This follows the built-in-compatible data-structure investigation in #516. The submitting account asked Codex to check the existing PRs and prepare another contribution if none had merged. The self-extension problem was found through source inspection and bounded regression tests, not in a production application.
AI assistance
Codex inspected the contribution guidance and previous PRs, wrote and ran the tests, implemented the fix, and prepared this PR. No independent human review or production usage is claimed.