Merge pull request #11096 from f321x/followup_11094
What changed, and why it matters
This commit is a small follow-up cleanup. It translates several user-facing error messages into different languages and makes the Qt GUI handle one specific file-read/write error (StorageReadWriteError) more gracefully, showing a warning dialog instead of a crash report. There is no direct evidence of a security vulnerability being fixed.
No immediate security action required. Treat as routine UX/localization improvement. If reviewing a related issue, verify whether StorageReadWriteError handling was incomplete in a prior security-relevant patch.
Security signals we found
Exception-handling path changed in GUI
User-facing error messages internationalized
No changes to encryption, wallet parsing semantics, or permissions
Evidence from the diff
The diff adds i18n (_) wrappers to WalletFileException and StorageReadWriteError messages in json_db.py, storage.py, wallet.py, and wallet_db.py, and imports StorageReadWriteError in electrum/gui/qt/init.py so the Qt exception handler treats it as a user-facing error rather than an unexpected crash. No cryptographic, authorization, or data-integrity logic is changed.
Changed components
electrum/gui/qt/__init__.pyelectrum/json_db.pyelectrum/storage.pyelectrum/wallet.pyelectrum/wallet_db.pyInspect captured patch +9 / −7
### electrum/gui/qt/__init__.py
@@ -73,6 +73,7 @@
standardize_path, UserFacingException)
from electrum.wallet import Wallet, Abstract_Wallet
from electrum.wallet_db import WalletRequiresSplit, WalletRequiresUpgrade, WalletUnfinished
+from electrum.storage import StorageReadWriteError
from electrum.gui import BaseElectrumGui
from electrum.simple_config import SimpleConfig
from electrum.wizard import WizardViewState
@@ -403,7 +404,7 @@ def start_new_window(
return None
def __handle_wallet_loading_exc(exc: Exception, pos):
- if isinstance(exc, UserFacingException) \
+ if isinstance(exc, (UserFacingException, StorageReadWriteError)) \
or isinstance(exc, WalletFileException) and not exc.should_report_crash:
self.logger.exception(f"{pos=}")
custom_message_box(icon=QMessageBox.Icon.Warning,
### electrum/json_db.py
@@ -30,7 +30,7 @@
import jsonpatch
import jsonpointer
-from . import util
+from .i18n import _
from .util import WalletFileException, profiler, sticky_property
from .logging import Logger
from .stored_dict import StoredDict, _FLEX_KEY, registered_names, registered_keys, _convert_dict_key, _convert_dict_value
@@ -128,9 +128,9 @@ def load_data(self, s: str) -> Dict[str, Any]:
data, patches = r, []
self.set_modified(True)
else:
- raise WalletFileException("Cannot read wallet file. (parsing failed)")
+ raise WalletFileException(_("Cannot read wallet file") + " (parsing failed)")
if not isinstance(data, dict):
- raise WalletFileException("Malformed wallet file (not dict)")
+ raise WalletFileException(_("Malformed wallet file") + " (not dict)")
if patches:
# apply patches
self.logger.info('found %d patches'%len(patches))
### electrum/storage.py
@@ -33,6 +33,7 @@
import electrum_ecc as ecc
from . import crypto
+from .i18n import _
from .util import (profiler, InvalidPassword, WalletFileException, bfh, standardize_path,
test_read_write_permissions, os_chmod)
@@ -80,7 +81,7 @@ def __init__(
try:
self.raw = f.read().decode("utf-8")
except UnicodeDecodeError as e:
- raise WalletFileException("Cannot read wallet file. (not an Electrum wallet file?)") from e
+ raise WalletFileException(_("Cannot read wallet file. (not an Electrum wallet file?)")) from e
self.pos = f.seek(0, os.SEEK_END)
self.init_pos = self.pos
self._encryption_version = self._init_encryption_version()
### electrum/wallet.py
@@ -4634,7 +4634,7 @@ def wallet_class(wallet_type):
return Multisig_Wallet
if wallet_type in wallet_constructors:
return wallet_constructors[wallet_type]
- raise WalletFileException("Unknown wallet type: " + str(wallet_type))
+ raise WalletFileException(_("Unknown wallet type: {}").format(wallet_type))
def create_new_wallet(
### electrum/wallet_db.py
@@ -356,7 +356,7 @@ def _convert_wallet_type(self):
d['seed'] = seed
self.put(key, d)
else:
- raise WalletFileException('Unable to tell wallet type. Is this even a wallet file?')
+ raise WalletFileException(_('Unable to tell wallet type. Is this even a wallet file?'))
# remove junk
self.put('master_public_key', None)
self.put('master_public_keys', None)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.