GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-161730: Fix the mode in the `compression.zstd.open()` invalid mode error by andresdelfino · Pull Request #161731 · python/cpython

Conversation

@andresdelfino

@andresdelfino andresdelfino commented Nov 10, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: compression.zstd.open() names the wrong mode in its invalid mode error #161730

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@andresdelfino @claude
pythongh-161730: Fix the mode in the compression.zstd.open() invalid …
16d968c
…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 <[email protected]>
@andresdelfino
andresdelfino requested review from AA-Turner and emmatyping as code owners November 10, 2026 02:37
@bedevere-app bedevere-app Bot mentioned this pull request Nov 10, 2026
compression.zstd.open() names the wrong mode in its invalid mode error #161730
Open
@bedevere-app bedevere-app Bot added the awaiting review label Nov 10, 2026
@aisk

aisk commented Nov 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The fix looks good to me, but I think it would be better to update the existing test to prevent regressions, perhaps by using assertRaisesRegex on this line:

cpython/Lib/test/test_zstd.py

Lines 2715 to 2716 in e891a91

with self.assertRaises(ValueError):
open(TESTFN, "rbt")

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andresdelfino

andresdelfino commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Sure, will do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andresdelfino @claude
Check the error message in the zstd invalid mode test
3738161
Co-Authored-By: Claude Opus 5.5 <[email protected]>
aisk
aisk approved these changes Nov 10, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aisk aisk aisk approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@emmatyping emmatyping Awaiting requested review from emmatyping emmatyping is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@andresdelfino @aisk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.