Skip to content

import aiohttp fails on 3.14 when zstd is not installed #11603

@ShaneHarvey

Description

@ShaneHarvey

Describe the bug

import aiohttp fails on 3.14 when Cpython is built without zstd support. The CPython docs neglect to mention that compression.zstd is optional. For example:

    import aiohttp
.tox/test/lib/python3.14/site-packages/aiohttp/__init__.py:6: in <module>
    from .client import (
.tox/test/lib/python3.14/site-packages/aiohttp/client.py:40: in <module>
    from . import hdrs, http, payload
.tox/test/lib/python3.14/site-packages/aiohttp/http.py:7: in <module>
    from .http_parser import (
.tox/test/lib/python3.14/site-packages/aiohttp/http_parser.py:29: in <module>
    from .compression_utils import (
.tox/test/lib/python3.14/site-packages/aiohttp/compression_utils.py:25: in <module>
    import compression.zstd  # noqa: I900
    ^^^^^^^^^^^^^^^^^^^^^^^
/opt/python/3.14/lib/python3.14/compression/zstd/__init__.py:29: in <module>
    import _zstd
E   ModuleNotFoundError: No module named '_zstd'

The compression.zstd import should guard against the ModuleNotFoundError/ImportError like it does for import zstandard on <=3.13.

To Reproduce

  1. Build CPython without zstd support.
  2. run import aiohttp

Expected behavior

No ImportError.

Logs/tracebacks

See above.

Python Version

3.14.0rc1

aiohttp Version

3.13.0

multidict Version

n/a

propcache Version

n/a

yarl Version

n/a

OS

RHEL 8

Related component

Client, Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions