Skip to content

Validate BarrelList pop indices before removing items - #575

Closed
ac1982 wants to merge 1 commit into
mahmoud:masterfrom
ac1982:fix/barrellist-pop-indices
Closed

ac1982 wants to merge 1 commit into
mahmoud:masterfrom
ac1982:fix/barrellist-pop-indices

Conversation

@ac1982

@ac1982 ac1982 commented Oct 12, 2026

Copy link
Copy Markdown

The change

BarrelList.pop(None), pop(()), pop(-1.0) and pop(0, 1) silently remove an item instead of raising TypeError. Objects implementing __index__ fail even though builtin list accepts them. Validate the argument count and normalize the index before touching partitioned storage.

Ten regression cases fail before the fix and pass after it, covering one/multiple partitions, rejected calls leaving contents unchanged, index objects, default/negative indices and empty-list errors. Full tests and doctests on Python 3.14.4/Linux: 688 passed and 12 subtests passed; diff whitespace checks pass. Other Python/platform matrix jobs were not run. The slice-deletion problem already tracked in #549 is outside this change.

The backstory

Earlier contributions from this account include #569 and #570. This issue was found while comparing the documented list-compatible API with builtin list during an automated contribution audit; it was not discovered in a production application. The concrete concern is that invalid calls mutate data rather than reporting the argument error.

AI assistance

  • Harness/tooling: Codex
  • Model(s): GPT-6
  • Original prompt(s): “开始今天的工作”; “完成 30 个有效 pr 在集中同步给我”. The accompanying repository instructions require substantive reproducible bugs, duplicate checks, upstream policy compliance, minimal fixes and tests; no patches are counted before an upstream PR exists. The agent selected and reproduced this issue, implemented the fix and ran the stated checks.

@Saadia751 Saadia751 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twenty-eight pop cases matched built-in list behavior with single-partition and fragmented BarrelList storage, including empty tail partitions. The cases covered omitted/default indices, positive/negative endpoints, bool indices, a custom index, None/float/string indices, out-of-range indices and too many arguments. I used Python 3.12.14 against commit 92604dc.

For invalid calls I compared exception types and verified that no item was removed; valid calls returned the same value and left the same sequence as list.pop. The empty-tail plus invalid-argument combination is useful here because validation must happen before cleanup/removal. These were standalone assertions against the fetched listutils module, not the full pytest suite.

@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.

3 participants