⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align itertools constructor binding and conversions - #9632

Draft
youknowdot wants to merge 8 commits into
RustPython:mainfrom
youknowdot:fix/itertools-constructor-binding-20261103
Draft

youknowdot wants to merge 8 commits into
RustPython:mainfrom
youknowdot:fix/itertools-constructor-binding-20261103

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Bind iterator constructor arguments before calling __iter__ in ten itertools constructors, and bind tee's optional count before invoking __index__. Preserve positional/keyword kinds and subclass keyword handling. This addresses unexpected-keyword side effects; Report a missing argument before converting any #9513 separately handles missing-argument precedence globally.
  • Align batched signed-size conversion, strict truth testing, partial-batch and source-error behavior, and align islice start/stop/step conversion ordering and ValueErrors with CPython 3.15.0.
  • Validate combinations sizes before consuming the iterable, preserve permutations' distinct pool-first/PyLong-only semantics, and distinguish an omitted repeat count from explicit None. Share the C-ssize conversion for the relevant counts and retain user conversion exceptions.

Validation

  • Independent source reviews against CPython 3.15.0, including an integration review of the combined changes.
  • prek run --files crates/vm/src/stdlib/itertools.rs and normal commit hooks passed.
  • Existing test_itertools covers standard constructor and iteration behavior, but direct coverage for some callback ordering, overflow and terminal-error cases was not found. No tests were edited and RustPython was not run locally; hosted CI is needed for build/runtime evidence.

This does not claim complete constructor parity: existing arity-versus-keyword diagnostic precedence, some allocation and argument/source lifetime differences, try_index normalization details, and concurrent iteration remain outside scope. Deferred iterator conversion retains the original argument for the constructor call and adds bounded reference-management work; no benchmark was run. zip_longest variadic iterator binding remains unchanged because deferring it would require a separately assessed temporary allocation.

Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

Bind the two required and two optional raw positional arguments together. Preserve explicit None values and deferred index conversion while removing the per-arity parsing branches.

Assisted-by: OpenAI Codex:model version not exposed
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.

1 participant