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 <grasson1101@aliyun.com>
Closes-Bug: #1416212
Change-Id: Ie5c81f1916e301619955364b040bdc7a9275e29c
This commit is contained in:
Davanum Srinivas 2015-02-01 15:00:48 -05:00
parent 28fd2cc531
commit 0366f880d5
2 changed files with 2 additions and 1 deletions

View File

@ -208,6 +208,7 @@ class IntegerTypeTests(TypeTestHelper, unittest.TestCase):
t(123)
t(300)
t(456)
self.assertRaises(ValueError, t, 0)
self.assertRaises(ValueError, t, 457)

View File

@ -144,7 +144,7 @@ class Integer(ConfigType):
else:
value = int(value)
if value:
if value is not None:
self._check_range(value)
return value