Skip to content

EndlessZstdDecompressor.decompress() rejects bytearray input with TypeError #74

Done

Description

@BLUESKY477

EndlessZstdDecompressor.decompress() raises TypeError for a bytearray, although data is documented as a bytes-like object and annotated as Buffer.

Environment: pyzstd 0.20.0, Python 3.12

Reproduction

import pyzstd

data = bytearray(pyzstd.compress(b"abc"))
pyzstd.EndlessZstdDecompressor().decompress(data)  # TypeError

Actual: TypeError (raised without a message)

Expected: b"abc". The docs say EndlessZstdDecompressor.decompress takes "the same parameters as ZstdDecompressor.decompress", where

:param data: Data to be decompressed.
:type data: bytes-like object

https://pyzstd.readthedocs.io/en/latest/pyzstd.html#pyzstd.EndlessZstdDecompressor.decompress

The method's own docstring also says data: A bytes-like object, zstd data to be decompressed.

Likely cause: the 0.19 rewrite checks isinstance(data, bytes) explicitly:

if not isinstance(data, bytes) or not isinstance(max_length, int):

so any other buffer (bytearray, memoryview) is rejected even though self._buffer += data would handle it. Converting with bytes(data) (or checking for the buffer protocol) would fix it. This touches the same method as #72 / #73.

Found while testing the library with an automated exploration tool; the reproduction above was re-run on 0.20.0 before filing.

Activity

  1. Rogdham commented on Nov 29, 2026

    @Rogdham
    Owner

    Thank you for the report, fixed in version 0.20.1.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions