Skip to content

Return None from bisect insort - #9630

Closed
youknowdot wants to merge 2 commits into
RustPython:mainfrom
youknowdot:fix/bisect-insort-return-none-20261103
Closed

youknowdot wants to merge 2 commits into
RustPython:mainfrom
youknowdot:fix/bisect-insort-return-none-20261103

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Consolidated into #9629

Closed after verifying #9629 at 1eae2eb5b1534c20bfd79f9befc0075661096136 includes this branch's latest head 28395170fc393de1ecb337ffe3abf23d4cf4c9df as an ancestor. Both insort result-disposal and argument-lifetime behavior are preserved. The final redundant-clone lint expectations are superseded by borrowed arguments.

The combined change passed native bisect tests, CPython 3.15 differential probes, full workspace and separate C-API Rust tests, and both strict Clippy runs.

Summary

Discard the result of a custom sequence's insert() in both _bisect.insort directions and return None, as CPython does. Keep the input and key objects alive through destruction of that result, so its finalizer cannot observe them being released prematurely. Search and insertion exceptions still propagate.

Scope and integration

Existing differences in lo/hi argument lifetime and callback order, as well as the lack of an exact-list native insertion fast path, remain separate. The bounds-order follow-on on #9629 now conflicts textually with this branch's insort hunks. A manually composed version retaining this PR's result-discard and ownership behavior has been independently source-reviewed; no merge has been performed.

Validation

  • Compared with CPython 3.15.0 _bisectmodule.c. CPython 3.15 reproductions confirmed both directions return None for an insert() returning a sentinel and release an ephemeral insertion result before the input and key objects.
  • Independent source review of this change and of the manual Align bisect bounds and callback controls #9629 composition, plus normal commit hooks (including rustfmt), passed.
  • RustPython was not built or executed locally. No tests were added or changed; hosted CI is expected to run existing bisect tests.

Discard the result of a custom insert method while retaining the input and key until that result is released, matching CPython.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Assisted-by: dot:frontier-intelligence
youknowdot pushed a commit to youknowdot/RustPython that referenced this pull request Nov 6, 2026
Absorb PR RustPython#9630 at 2839517. Its result-disposal fix is already included. The final redundant-clone expectations are superseded by borrowed arguments, which retain inputs through result disposal without those clones.

Assisted-by: dot:frontier-intelligence
@youknowone youknowone closed this Nov 6, 2026
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