Integer(0) will return 0 even 0 is not in the range specified
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.config |
Fix Released
|
Undecided
|
Davanum Srinivas (DIMS) |
Bug Description
THe line in Integer.__call__ should compare None , not False:
def __call__(self, value):
if not isinstance(value, int):
....
if value:
return value
Should be modified as:
def __call__(self, value):
if not isinstance(value, int):
....
if value is not None:
return value
How to reproduce the problem:
>>> from oslo.config import types
>>> Test1 = types.Integer(3,6)
>>> Test1(0)
0
After modification:
>>> from oslo.config import types
>>> Test1 = types.Integer(3,6)
>>> Test1(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
self.
File "/usr/lib/
self.min)
ValueError: Should be greater than or equal to 3
Changed in oslo.config: | |
assignee: | nobody → Davanum Srinivas (DIMS) (dims-v) |
status: | New → In Progress |
Changed in oslo.config: | |
milestone: | none → 1.7.0 |
status: | Fix Committed → Fix Released |
Reviewed: https:/ /review. openstack. org/151940 /git.openstack. org/cgit/ openstack/ oslo.config/ commit/ ?id=0366f880d52 22251ce4b6833fa 556d11d1e47229
Committed: https:/
Submitter: Jenkins
Branch: master
commit 0366f880d522225 1ce4b6833fa556d 11d1e47229
Author: Davanum Srinivas <email address hidden>
Date: Sun Feb 1 15:00:48 2015 -0500
Better check for integer range to account for 0
We should be using "if value is not None" to better check
for the condition where the value is 0 and 0 is not in the
valid range.
Co-Authored-By: Longjie_Cao <email address hidden> 619955364b040bd c7a9275e29c
Closes-Bug: #1416212
Change-Id: Ie5c81f1916e301