Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/11603.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed Python 3.14 support when built without ``zstd`` support -- by :user:`JacobHenner`.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Ivan Lakovic
Ivan Larin
J. Nick Koston
Jacob Champion
Jacob Henner
Jaesung Lee
Jake Davis
Jakob Ackermann
Expand Down
18 changes: 9 additions & 9 deletions aiohttp/compression_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@
except ImportError:
HAS_BROTLI = False

if sys.version_info >= (3, 14):
import compression.zstd # noqa: I900
try:
from compression.zstd import ( # type: ignore[import-not-found] # noqa: I900
ZstdDecompressor,
)

HAS_ZSTD = True
else:
except ImportError:
try:
import zstandard
from zstandard import ZstdDecompressor

HAS_ZSTD = True
except ImportError:
HAS_ZSTD = False


MAX_SYNC_CHUNK_SIZE = 1024


Expand Down Expand Up @@ -297,13 +300,10 @@ def __init__(self) -> None:
"The zstd decompression is not available. "
"Please install `zstandard` module"
)
if sys.version_info >= (3, 14):
self._obj = compression.zstd.ZstdDecompressor()
else:
self._obj = zstandard.ZstdDecompressor()
self._obj = ZstdDecompressor()

def decompress_sync(self, data: bytes) -> bytes:
return self._obj.decompress(data)
return self._obj.decompress(data) # type: ignore[no-any-return]

def flush(self) -> bytes:
return b""
Loading