elif comp_type.startswith(b'xzkern'):
raise NotImplementedError('xzkern decompression not implemented')
elif comp_type.startswith(b'zstd'):
- zstd = try_import('zstandard')
- data = f.read(size)
- return cast(bytes, zstd.ZstdDecompressor().stream_reader(data).read())
+ try:
+ zstd = try_import('compression.zstd')
+ data = f.read(size)
+ return cast(bytes, zstd.zstd.ZstdDecompressor().decompress(data))
+ except ValueError:
+ zstd = try_import('zstandard')
+ data = f.read(size)
+ return cast(bytes, zstd.ZstdDecompressor().stream_reader(data).read())
raise NotImplementedError(f'unknown compressed type: {comp_type!r}')
return cast(bytes, gzip.open(f).read())
if start.startswith(b'\x28\xb5\x2f\xfd'):
- zstd = try_import('zstandard')
- return cast(bytes, zstd.ZstdDecompressor().stream_reader(f.read()).read())
+ try:
+ zstd = try_import('compression.zstd')
+ return cast(bytes, zstd.zstd.ZstdDecompressor().decompress(f.read()))
+ except ValueError:
+ zstd = try_import('zstandard')
+ return cast(bytes, zstd.ZstdDecompressor().stream_reader(f.read()).read())
if start.startswith(b'\x02\x21\x4c\x18'):
lz4 = try_import('lz4.frame', 'lz4')