Contribution to Autobahn|Python
, the WebSocket and WAMP (Web Application Messaging Protocol) implementation for Python’s Twisted and asyncio frameworks. The work fixes a regression that broke import autobahn.twisted on CPython 3.11–3.13 when an older zope.interface was installed. It also adds CI coverage so that version floors which are too low get caught before a release. The bug surfaced on a FreeBSD jail, where a freshly installed Buildbot worker would not start.
The import failure
Since release 26.6.1, importing autobahn.twisted.util failed on CPython 3.11–3.13 when the installed zope.interface was older than 6.2:
TypeError: unsupported operand type(s) for |: 'InterfaceClass' and 'InterfaceClass'
An earlier linter-driven cleanup had rewritten Union[A, B] annotations to the A | B form. Without from __future__ import annotations, Python before 3.14 evaluates annotations when the module loads. Twisted interfaces such as ITransport and IProcessTransport are zope.interface InterfaceClass instances, and these support the | operator only from zope.interface 6.2 on. Autobahn still declared zope.interface>=5.2.0, and CI always installed a recent version, so nothing caught the gap. An earlier audit had looked only at quoted forward references ("X" | None), so it missed this variant.
Reported the issue with a one-line reproduction and the affected lines. The maintainer agreed with the analysis and invited a pull request for the fix:
- Added
from __future__ import annotationstoautobahn/twisted/util.pyandautobahn/twisted/wamp.py, so their annotations are no longer evaluated at import time. - Raised the
zope.interfacefloor in thetwistedextra from>=5.2.0to>=6.2, the first release with|support on interfaces. Autobahn importszope.interfacedirectly, so it must declare its own floor instead of relying on Twisted’s lower one. The floor also keeps the declared requirement true for tools that still evaluate annotations at runtime, such astyping.get_type_hints().
The maintainer confirmed both points locally: the bug reproduces with zope.interface 5.5.2 on master and is gone with the fix, and 6.1 still fails while 6.2 works, so 6.2 is exactly the right floor.
Catching stale version floors in CI
The root cause was a version floor that nobody tested. To catch this class of bug, the PR adds:
- A
just test-imports-lowestrecipe and animport-smoke-lowestCI job. They installautobahn[all]withuv --resolution lowest-direct, so every direct dependency resolves to the lowest version thatpyproject.tomlallows, and then run the import smoke test. The job runs on both CPython 3.11 and PyPy 3.11, because PyPy’s lowest resolution can differ for cffi-based dependencies. - An extended import smoke test that also covers the Twisted and asyncio binding modules. Each module is imported in a fresh interpreter, because
txaiocan select only one backend per process.
Two packages had to be lifted above their lowest versions in the recipe: pyOpenSSL before 22.1.0 does not cap cryptography and breaks at import against current releases, and Twisted 22.10.0 uses import attrs while declaring an older attrs floor. Both are metadata problems in other projects, not in Autobahn, so the workarounds stay documented in the test recipe instead of raising Autobahn’s own floors. The new tests fail on the old code with zope.interface 5.5.2 and pass with the fix.
Review and CI fixes
The first CI run failed in the combined coverage step: every Twisted module in the new test raised RuntimeError: Explicitly using 'asyncio' already. The asyncio half of the test suite runs with USE_ASYNCIO=1, and the child interpreters inherited it, so autobahn/__init__.py selected the asyncio backend before the Twisted binding could select its own. Following the review, the test now:
- Starts each child interpreter without
USE_TWISTEDandUSE_ASYNCIO, so every module must select its backend itself, as it does for a user who sets neither. - Asserts which
txaiobackend each module selected. This catches a Twisted module that silently stops selecting Twisted, and an asyncio module that pulls Twisted in. - Carries a comment on the
zope.interfaceline inpyproject.tomlthat explains the floor, so nobody later lowers it again or raises the neighbouring floors along with it.
The Windows wheel builds also broke during the review. Since cryptography 50.0.2, its Windows PyPy wheel targets PyPy 8 only, while the project’s PyPy environment is pinned to PyPy 7.3. Pip therefore fell back to building cryptography from source and failed with “Could not find directory of OpenSSL installation”. A second commit extends the existing ARM64-only OpenSSL build step via vcpkg to Windows x86_64 too.
The PR was merged on 2026-10-06. The broader cleanup, adding from __future__ import annotations to every typed module and enforcing it with ruff, is tracked as a separate issue
.