Skip to content

Commit fcd9830

Browse files
committed
Do not use assert for functional behavior
assert should not be used for functional code paths. It can be disabled via Python command line option -O. In that case __full_version__ would not be set to "unknown". Use an explicit exception instead.
1 parent 9eb9935 commit fcd9830

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

programmer/tinyprog/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
try:
2424
from .full_version import __full_version__
25-
assert __full_version__
26-
except (ImportError, AssertionError):
25+
if not __full_version__:
26+
raise ValueError
27+
except (ImportError, ValueError):
2728
__full_version__ = "unknown"
2829

2930

0 commit comments

Comments
 (0)