Skip to content

Commit c67ed62

Browse files
authored
Fix 1767 (#1769)
* add branch audit file * Fix NVX runtime detection to check actual CFFI modules Problem: When installing from source with AUTOBAHN_USE_NVX=0 (no NVX build), the runtime detection incorrectly reported HAS_NVX=True, causing crashes when attempting to use NVX functionality. Root Cause: The detection was importing Python wrapper modules (autobahn.nvx._xormasker and autobahn.nvx._utf8validator) which are always importable as they're Python files. The actual CFFI extension modules (_nvx_xormasker and _nvx_utf8validator) are only imported lazily inside the wrapper classes' __init__ methods, so their availability wasn't being checked. Solution: Changed detection to directly import the CFFI extension modules: - import _nvx_utf8validator - import _nvx_xormasker This correctly detects whether NVX was actually built at install time: - If NVX was built: CFFI modules exist → HAS_NVX=True - If NVX wasn't built: CFFI modules don't exist → ImportError → HAS_NVX=False Testing: - With CFFI modules available: HAS_NVX=True, USES_NVX=True ✓ - With CFFI modules blocked: HAS_NVX=False, USES_NVX=False ✓ This ensures the pure Python fallback is correctly used when NVX isn't built. Fixes #1767 Note: This work was completed with AI assistance (Claude Code).
1 parent 0b8d651 commit c67ed62

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.audit/oberstet_fix_1767.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- [ ] I did **not** use any AI-assistance tools to help create this pull request.
2+
- [x] I **did** use AI-assistance tools to *help* create this pull request.
3+
- [x] I have read, understood and followed the projects' [AI Policy](https://github.com/crossbario/autobahn-python/blob/main/AI_POLICY.md) when creating code, documentation etc. for this pull request.
4+
5+
Submitted by: @oberstet
6+
Date: 2025-11-21
7+
Related issue(s): #1767
8+
Branch: oberstet:fix_1767

autobahn/websocket/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
# Step 1: Probe for NVX availability (was it built and can we import it?)
4444
_has_nvx = False
4545
try:
46-
# Try importing both NVX modules to verify they're available
47-
from autobahn.nvx._xormasker import create_xor_masker as _nvx_xor_test # noqa: F401
48-
from autobahn.nvx._utf8validator import Utf8Validator as _nvx_utf8_test # noqa: F401
46+
# Try importing the actual CFFI extension modules directly
47+
# (not just the Python wrappers which are always importable)
48+
# This correctly detects if NVX was actually built at install time
49+
import _nvx_utf8validator # noqa: F401
50+
import _nvx_xormasker # noqa: F401
4951

5052
_has_nvx = True
5153
except ImportError:

0 commit comments

Comments
 (0)