Skip to content

Align in-memory I/O position controls - #9675

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:io-memory-position-controls-20261103
Nov 6, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:io-memory-position-controls-20261103

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Convert BytesIO/StringIO.seek(pos, whence) arguments in order and keep BytesIO positions within the signed-size range, including negative relative seeks and overflow.
  • Check closed/exported state before truncate's index conversion using shared typed argument binding; release storage locks during callbacks and recheck state afterward.
  • Reject overflowing nonempty BytesIO writes before allocation, while preserving empty writes at the maximum position.

Uses existing numeric conversion and buffer-resize guards, with no per-method FuncArgs parser. Post-index closed/export rechecks are intentional Rust safety checks: CPython's truncate bodies check those conditions before conversion only.

Reference: CPython 3.15.0 BytesIO, StringIO, and seek argument conversion.

Validation

  • Bounded CPython 3.15 reference probes confirmed conversion order, closed/exported precedence, negative seeks, overflow, and truncate callbacks that move the position.
  • Rust formatting and git diff --check passed.
  • Focused host-env, VM and stdlib package check and strict Clippy passed against the final source. Normal repository commit hooks passed.
  • RustPython runtime tests, full workspace/C-API tests, and cross-platform execution were not run. No test, Lib, workflow, or expected-failure marker edits.

AI assistance: OpenAI Codex performed source comparison, implementation, reference probes, and independent source review; model version was not exposed.

Use typed seek parameters in conversion order, enforce signed BytesIO
positions, and delay truncate index conversion until state validation.
Recheck stream state after index callbacks without holding storage locks.
Guard overflowing nonempty writes before allocation and remove obsolete
conversion helpers.

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

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@codspeed

codspeed Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:io-memory-position-controls-20261103 (9e91df9) with main (0b081b0)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@youknowone
youknowone marked this pull request as ready for review November 6, 2026 10:37
@youknowone
youknowone merged commit 6560ea7 into RustPython:main Nov 6, 2026
29 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T10:37:36.210523Z
We couldn’t complete this review. Comment @codex review to try again.
9e91df9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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