Skip to content

Flush the caller's file object before starting the compressor - #189

Open
rpinho wants to merge 1 commit into
pycompression:mainfrom
rpinho:fix-flush-before-compressor
Open

rpinho wants to merge 1 commit into
pycompression:mainfrom
rpinho:fix-flush-before-compressor

Conversation

@rpinho

@rpinho rpinho commented Dec 2, 2026

Copy link
Copy Markdown

Who hits this: users who write compressed members to an open binary file and then use xopen(file, "ab") (#149).

The compressor writes to the file descriptor before Python flushes what is still in the buffer. With two XZ members, both decode fine, but in reverse order.

Now it flushes the file object before the child process takes over. Read modes and paths are the same. It has a test for this. One thing I didn't do: for a TextIOWrapper, only .buffer is flushed, not the pending text.

I'm doing this with AI agents. A second agent on a different model checked the bug again from the report alone, without the first agent's code.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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