Merge pull request #1785 from tiagobar/master

Enhances/fixes validators/is_empty() for Python 3 compatibility, fix #1764
This commit is contained in:
mdipierro
2017-10-18 22:12:09 -05:00
committed by GitHub
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -444,6 +444,8 @@ class TestValidators(unittest.TestCase):
self.assertEqual(rtn, (None, 'Enter a value'))
rtn = IS_NOT_EMPTY()('')
self.assertEqual(rtn, ('', 'Enter a value'))
rtn = IS_NOT_EMPTY()(b'')
self.assertEqual(rtn, (b'', 'Enter a value'))
rtn = IS_NOT_EMPTY()(' ')
self.assertEqual(rtn, (' ', 'Enter a value'))
rtn = IS_NOT_EMPTY()(' \n\t')
+1 -1
View File
@@ -996,7 +996,7 @@ def is_empty(value, empty_regex=None):
value = value.strip()
if empty_regex is not None and empty_regex.match(value):
value = ''
if value is None or value == '' or value == []:
if value is None or value == '' or value == b'' or value == []:
return (_value, True)
return (_value, False)