diff --git a/electrum/__init__.py b/electrum/__init__.py index f806c548b..f4c355028 100644 --- a/electrum/__init__.py +++ b/electrum/__init__.py @@ -35,5 +35,15 @@ from .logging import get_logger __version__ = ELECTRUM_VERSION _logger = get_logger(__name__) -if not __debug__: - _logger.warning(f"__debug__ is False. running with asserts disabled!") + + +# Ensure that asserts are enabled. For sanity and paranoia, we require this. +# Code *should not rely* on asserts being enabled. In particular, safety and security checks should +# always explicitly raise exceptions. However, this rule is mistakenly broken occasionally... +try: + assert False +except AssertionError: + pass +else: + raise ImportError("Running with asserts disabled. Refusing to continue. Exiting...") + diff --git a/run_electrum b/run_electrum index 36d9817b9..79eddd15f 100755 --- a/run_electrum +++ b/run_electrum @@ -63,19 +63,6 @@ if is_pyinstaller: # causes ImportErrors and other runtime failures). (see #4072) _file = open(sys.executable, 'rb') -if is_binary_distributable: - # Ensure that asserts are enabled. - # Code *should not rely* on asserts being enabled. In particular, safety and security checks should - # always explicitly raise exceptions. However, this rule is mistakenly broken occasionally... - # In case we are a binary build, we know for a fact that we want the asserts, so enforce them. - # When running from source, defer to the user. (a warning is logged in __init__.py) - try: - assert False - except AssertionError: - pass - else: - sys.exit("Error: Running with asserts disabled, in a binary distributable! Please check build settings.") - def check_imports(): # pure-python dependencies need to be imported here for pyinstaller