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 — `compression.zstd.open()` names the wrong mode in its invalid mode error · Issue #161730 · python/cpython

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

New issue
Copy link
New issue
Copy link
Open
Open
compression.zstd.open() names the wrong mode in its invalid mode error#161730
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@andresdelfino
andresdelfino
opened on Nov 10, 2026
Issue body actions

Bug report

Bug description:

compression.zstd.open() rejects a mode that contains both 't' and 'b', but the error message names a different mode than the one passed:

>>> import io
>>> from compression import zstd
>>> zstd.open(io.BytesIO(zstd.compress(b'x')), 'rtb')
Traceback (most recent call last):
  ...
ValueError: Invalid mode: 'rb'

'rb' is a valid mode. open() removes 't' from the mode before checking for 'b', and the message is formatted with the modified string:

text_mode = 't' in mode
mode = mode.replace('t', '')

if text_mode:
    if 'b' in mode:
        raise ValueError(f'Invalid mode: {mode!r}')

gzip.open(), bz2.open() and lzma.open() report the mode as passed (Invalid mode: 'rtb').

CPython versions tested on:

3.14, 3.15, CPython main branch

Operating systems tested on:

Linux

Linked PRs

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

Activity

  1. aisk
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 10, 2026
  2. aisk
    added this to Compression issues 🗜on Nov 10, 2026
  3. aisk
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Compression issues 🗜
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.