⚡ Sangsakala Proxy 🏠 Home
Skip to content

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

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:io-memory-position-controls-20261103
Draft

youknowdot wants to merge 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

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

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

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