Allow None in Greater/Less PYSON

issue5711
review32311002
This commit is contained in:
Cédric Krier committed 2016-07-19 07:45:18 +07:00
1 parent 300abc0a38
commit a686741e67
1 file changed
+4 -2
+4 -2
View File
@@ -315,10 +315,10 @@ class Greater(PYSON):
super(Greater, self).__init__()
for i in (statement1, statement2):
if isinstance(i, PYSON):
assert i.types().issubset(set([int, long, float])), \
assert i.types().issubset({int, long, float, type(None)}), \
'statement must be an integer or a float'
else:
assert isinstance(i, (int, long, float)), \
assert isinstance(i, (int, long, float, type(None))), \
'statement must be an integer or a float'
if isinstance(equal, PYSON):
assert equal.types() == set([bool])
@@ -346,6 +346,8 @@ class Greater(PYSON):
@staticmethod
def _convert(dct):
for i in ('s1', 's2'):
if dct[i] is None:
dct[i] = 0.0
if not isinstance(dct[i], (int, long, float)):
dct = dct.copy()
dct[i] = float(dct[i])