Repository navigation
Conversation
|
The following commit authors need to sign the Contributor License Agreement: |
truncate() delegated to the buffer without an explicit position, so the stream was resized to wherever the buffer had read ahead to rather than to the current position of the text stream. _pyio passes tell() through and already behaves correctly, so this only changes the C implementation.
b4be619 to
800bd26
Compare
|
Please read and review the https://devguide.python.org/, in particular the parts around using AI and the lifecycle of a PR (https://devguide.python.org/getting-started/pull-request-lifecycle/). Don't force push to branches which are in Python PRs: https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push |
|
That force push was mine and it won't happen again. I was fixing an unresolvable On disclosure: I use Claude Code, and it's noted at the bottom of the PR description. The Happy to go through any of it. Also, if you'd rather I close the two |
The buffer that a
TextIOWrappersits on top of reads ahead, so after a read itsposition is not the position of the text stream.
truncate()with no argument passednothing through to the buffer, so the stream was resized to the read-ahead position:
With a file bigger than one chunk it truncates to 8192 instead.
io.BufferedRandomgets this right, and so does
_pyio.TextIOWrapper, which passestell()to thebuffer. The test added here fails on the C implementation and passes on the Python one
before the fix, so no
_pyiochange is needed -- this only brings_iointo line.Refs gh-161275.
🤖 Generated with Claude Code