Skip to content

Restore Python 3.15 TextIOWrapper chunk-size deletion semantics - #9082

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/textiowrapper-chunk-size-python315
Oct 11, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/textiowrapper-chunk-size-python315

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Restore final Python 3.15 TextIOWrapper._CHUNK_SIZE deletion behavior after the Python 3.14.8-specific change from #9071 landed alongside #8950.

  • Check initialization and buffer attachment before rejecting deletion.
  • Raise AttributeError("cannot delete attribute") for attached wrappers, including subclasses. Uninitialized and detached wrappers retain their precise ValueError contracts.
  • Preserve every existing initialized, uninitialized, detached, ASCII-subclass, and non-ASCII-subclass regression case with exact final-reference exception types and messages. No skips or relaxed assertions are added.
  • Leave assignment conversions, overflow/positive-size validation, and locking around the final write unchanged.

No files under Lib/ are changed. This is one shared-main correction; it does not duplicate the fix across the existing leaf PRs.

Reference: CPython v3.15.0 setter.

Failure evidence

The unrelated workflow-only #8958 fails the CPython 3.15 stdlib_io.py reference test on Windows and macOS. #9058 shows the same failure on Linux. The assertion was introduced by #9071, not the leaf changes. Other tests in those completed snippet jobs pass.

Validation

Candidate: ef1197a5e2477b719670768089033af1098a41ee, directly on main 06007c81fa99e813cbf4583dab326764ba0ef017.

  • Normal commit hooks, whitespace checks, and independent source/coverage review pass.
  • A certified, unpatched CPython build from the exact v3.15.0 source passes the bounded existing chunk-size cases. A separate 12-case in-memory probe confirms attached/closed/uninitialized/detached behavior for the base class and both subclass names.
  • A fresh native interpreter build at ef1197a passes the same bounded existing cases and matches all 12 reference outcomes exactly. All workspace-package artifacts were cleared before rebuilding; the binary reports the expected commit and source/binary fingerprints were recorded.
  • Warnings-denied VM-library and root-interpreter Clippy pass. No broad local suite was executed, and hosted cross-platform CI is pending.

AI assistance

OpenAI Codex assisted with diagnosis, implementation, independent review, and validation. The runtime does not expose a precise model identifier; the commit includes an Assisted-by trailer.

Check initialization and attachment before rejecting deletion, and use the final reference error message. Preserve initialized, uninitialized, detached, ASCII-subclass, and non-ASCII-subclass regression cases with their exact Python 3.15 outcomes. No bundled Lib files change.

Assisted-by: OpenAI Codex:model identifier unavailable
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1959d7ef-2aa0-493c-8de5-07c97dc4b8e6

📥 Commits

Reviewing files that changed from the base of the PR and between 06007c8 and ef1197a.


📒 Files selected for processing (2)
  • crates/vm/src/stdlib/_io.rs
  • extra_tests/snippets/stdlib_io.py

 ________________________________________________
< Love the optimism of `// should never happen`. >
 ------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • 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

Comment @coderabbitai help to get the list of available commands.

@youknowone
youknowone marked this pull request as ready for review October 11, 2026 12:35
@youknowone
youknowone merged commit d88c935 into RustPython:main Oct 11, 2026
30 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T12:39:07.668928Z ef1197a 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 chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef1197a5e2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

assert str(error.exception) == (
"attribute '_CHUNK_SIZE' of '_io.TextIOWrapper' objects cannot be deleted"
)
assert str(error.exception) == message

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the existing snippet assertions

AGENTS.md explicitly forbids deleting test lines or modifying assertions, test logic, or test data, but this replacement changes the expected exception type and message for each existing deletion case (and the following hunk also removes the subclass-name expectation). Rework the change without altering these test assertions rather than updating their oracle alongside the implementation.

AGENTS.md reference: AGENTS.md:L274-L275

Useful? React with 👍 / 👎.

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