Skip to content

gh-85393: Handle partial and blocking .write in TextIOWrapper #134467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cmaloney
Copy link
Contributor

@cmaloney cmaloney commented May 21, 2025

Also improves non-blocking support (gh-57531) and unbuffered support (gh-61606)

While behavior doesn't (generally) change it adds a lot of new warnings so I feel this is more of a feature (support non-blocking and unbuffered!) than a bugfix.

TODO before non-Draft

  • Review what type each warning should be
  • Validate if should warn on None (if so, fix CPython test cases)
  • Implement a blocking I/O write test like the one for BufferedIO (test_nonblock_pipe_write_bigbuf)
  • Add a partial write test

Also improves non-blocking support (pythongh-57531) and unbuffered support (pythongh-61606)
@cmaloney cmaloney force-pushed the wip/blocking_partial_io branch from 696abe7 to 4173474 Compare May 21, 2025 20:56
@cmaloney
Copy link
Contributor Author

I'm at the PyConUS sprints, would appreciate a high-level review / if the approach I took here looks like what you expect. In particular I tried to keep behavior around all the unexpected potential return values from buffer.write but also add DeprecationWarning/RuntimeWarning for many. I'm planning to work on expanding tests for this tomorrow (clone of BufferedIO blocking test, tests for underlying writers that return all the bad values, partial write tests, etc).

cc: @vstinner, @serhiy-storchaka (commented on the underlying issue, but also was quite a while ago. If there's better experts or someone more appropriate let me know)

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