unconditionally raise ImportError if asserts are disabled
I have reconsidered and now think that we should always hard-fail if asserts asserts are disabled. It is just easier to reason about the code knowing that asserts are evaluated. If an end-user or library user has a concrete use case where this is a problem, please open an issue and let us know. follow-up0f541be6f10e5464ca13
This commit is contained in:
13
run_electrum
13
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
|
||||
|
||||
Reference in New Issue
Block a user