What changed, and why it matters
This commit changes a single line in Electrum's crypto library. Previously, if required encryption packages were missing, the library would abruptly terminate the entire program with sys.exit. Now it raises a standard ImportError instead, which is the normal Python way to report a missing dependency. This is a code-quality and robustness improvement, not a fix for an active security vulnerability. The main practical benefit is that other programs importing Electrum's crypto module will get a catchable exception rather than having their process killed.
No urgent action required. Treat as a normal robustness improvement. Reviewers may want to verify that run_electrum and other entry points still handle the ImportError appropriately and present a user-friendly message, since the library no longer exits on its own.
Security signals we found
Library module previously called sys.exit on missing dependency, causing unclean process termination for importers
Failure mode now raises ImportError, which callers can catch and handle gracefully
No memory corruption, cryptographic weakness, or input-validation issue is present in the diff
Evidence from the diff
In electrum/crypto.py, the fallback block that runs when neither pycryptodomex nor cryptography is installed was changed from sys.exit(…) to raise ImportError(…). This removes an inappropriate sys.exit call from a library module. The change makes the failure mode more predictable for callers and aligns with Python conventions. There is no evidence in the commit of a security bug being fixed; it is a defensive-coding cleanup.
Changed components
electrum/crypto.pyInspect captured patch +1 / −1
diff --git a/electrum/crypto.py b/electrum/crypto.py
index f67b099..ad46e38 100644
--- a/electrum/crypto.py
+++ b/electrum/crypto.py
@@ -83,7 +83,7 @@ else:
if not (HAS_CRYPTODOME or HAS_CRYPTOGRAPHY):
- sys.exit(f"Error: at least one of ('pycryptodomex', 'cryptography') needs to be installed.")
+ raise ImportError(f"Error: at least one of ('pycryptodomex', 'cryptography') needs to be installed.")
def version_info() -> Mapping[str, Optional[str]]:
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.