Skip to content

gh-161730: Fix the mode in the compression.zstd.open() invalid mode error - #161731

Open
andresdelfino wants to merge 1 commit into
python:mainfrom
andresdelfino:zstd-open-invalid-mode-message
Open

andresdelfino wants to merge 1 commit into
python:mainfrom
andresdelfino:zstd-open-invalid-mode-message

Conversation

@andresdelfino

@andresdelfino andresdelfino commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

compression.zstd.open() removed 't' from the mode before checking for the invalid 't' and 'b' combination, and formatted the error message with the modified string. For 'rtb' the message was Invalid mode: 'rb', which names a valid mode the caller didn't pass. This moves the mode.replace('t', '') call after the check, so the message shows the mode as passed (Invalid mode: 'rtb'), like gzip.open(), bz2.open() and lzma.open().

🤖 Generated with Claude Code

…mode error

compression.zstd.open() removed 't' from the mode before checking for
the invalid 't' and 'b' combination, so the error message named the
modified mode (e.g. "Invalid mode: 'rb'" for 'rtb'), which is a valid
mode the caller didn't pass.  Check before removing 't', matching
gzip.open(), bz2.open() and lzma.open().

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant