util: use FileNotFoundError for dangling symlink
What changed, and why it matters
This is a tiny code-quality change: when Electrum's helper function detects a broken symbolic link (a 'dangling symlink') while creating a directory, it now raises a more specific Python error type (FileNotFoundError) instead of a generic Exception. The behavior is the same; only the error class is more precise. It is not a security fix and does not change how an attacker could exploit the software.
No security action required. Treat as a normal code-cleanup commit.
Security signals we found
No security-relevant behavioral change
Exception-type refinement only
No input validation, sandboxing, or cryptographic changes
Evidence from the diff
In electrum/util.py, make_dir() checks whether a path is a dangling symlink and raises an error before calling os.mkdir(). The patch changes the raised exception from the generic Exception class to FileNotFoundError. No control flow, validation, or privilege logic is altered. The change improves exception specificity and may help callers handle this case more cleanly, but it does not address a vulnerability.
Changed components
electrum/util.py::make_dir()Inspect captured patch +1 / −1
diff --git a/electrum/util.py b/electrum/util.py
index 5223d85..45d90ab 100644
--- a/electrum/util.py
+++ b/electrum/util.py
@@ -1172,7 +1172,7 @@ def make_dir(path, *, allow_symlink=True):
"""
if not os.path.exists(path):
if not allow_symlink and os.path.islink(path):
- raise Exception('Dangling link: ' + path)
+ raise FileNotFoundError('Dangling link: ' + path)
try:
os.mkdir(path)
except FileExistsError:
Why this scored 18/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.