Do not use asserts with business logic
a piece of code in node object was relying on result of 'assert' to block negative values of properties. When running Python in optimized mode (-OO) this assert will be swallowed and negative values may slip through. Replace this line with proper if-block. Change-Id: Iec1edc55219cfd6c54afa52c1ecd0cf76340bddf
This commit is contained in:
parent
180234b445
commit
a61ee9429a
|
@ -148,8 +148,9 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||
continue
|
||||
try:
|
||||
int_value = int(value)
|
||||
assert int_value >= 0
|
||||
except (ValueError, AssertionError):
|
||||
if int_value < 0:
|
||||
raise ValueError("Value must be non-negative")
|
||||
except (ValueError, TypeError):
|
||||
msg = (('%(param)s=%(value)s') %
|
||||
{'param': param, 'value': value})
|
||||
invalid_msgs_list.append(msg)
|
||||
|
|
Loading…
Reference in New Issue