Skip to content

gh-150599: Prevent bz2 decompressor reuse after errors#150600

Open
StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:bz2-store
Open

gh-150599: Prevent bz2 decompressor reuse after errors#150600
StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:bz2-store

Conversation

@StanFromIreland
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland commented May 30, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Why reraise the same error again and again? Why not close the decomressor, set eof and raise EOFError? Or set other flag and raise ValueError or RuntimeError?

@StanFromIreland
Copy link
Copy Markdown
Member Author

Serhiy, FYI this is the fix for: https://github.com/python/cpython/security/advisories/GHSA-mv83-7xc2-cc7v

Why reraise the same error again and again? Why not close the decomressor, set eof and raise EOFError? Or set other flag and raise ValueError or RuntimeError?

Setting eof and raising EOFError would lie about the state as the stream did not finish cleanly. ValueError/RuntimeError would make the second call report a different kind of failure from the first call, even though the root cause is the same. I think re-raising the same exception is the most useful behaviour, it preserves the original failure reason.

@serhiy-storchaka
Copy link
Copy Markdown
Member

You are not supposed to use decompressor after failure. Raising a ValueError or a RuntimeError with specific error message ("decompressor is dead, don't use it") will make it clear.

@StanFromIreland
Copy link
Copy Markdown
Member Author

You are not supposed to use decompressor after failure. Raising a ValueError or a RuntimeError with specific error message ("decompressor is dead, don't use it") will make it clear.

It is clear, I'm still leaning towards providing the root cause being more helpful. Greg and Emma, what do you think is better here?

@serhiy-storchaka
Copy link
Copy Markdown
Member

You already got the initial error first time. There is no precedence of keeping the original error and raising it on recurring requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants