Python 3.14+compression.zstdexception
compression.zstd.ZstdError
in-memory compression
The compression.zstd exception for a Zstandard library error during compression or decompression, such as data not in zstd format.
Syntax
except compression.zstd.ZstdError:
It derives from Exception, not OSError or ValueError, so a broad except OSError around file reading lets it through. The typical cause is passing decompress data in another format (gzip, zlib) or a truncated stream. A bad compression parameter, by contrast, gives ValueError or TypeError before the library is called. The module appeared in 3.14; older versions have neither it nor the exception.
Examples
from compression import zstd
try:
zstd.decompress(b'not zstd data')
except zstd.ZstdError as err:
print(type(err).__name__) # → ZstdError
print(issubclass(zstd.ZstdError, OSError)) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy