File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ Next Release (TBD)
2
+ ==================
3
+
4
+ * Fix issue where long types in py2 and ``Decimal `` types
5
+ were not being evaluated as numbers
6
+ (`issue 125 <https://github.com/jmespath/jmespath.py/issues/125 >`__)
7
+
8
+
1
9
0.9.2
2
10
=====
3
11
Original file line number Diff line number Diff line change 2
2
3
3
from jmespath import functions
4
4
from jmespath .compat import string_type
5
+ from numbers import Number
5
6
6
7
7
8
def _equals (x , y ):
@@ -52,7 +53,7 @@ def _is_actual_number(x):
52
53
# True
53
54
if x is True or x is False :
54
55
return False
55
- return isinstance (x , ( float , int ) )
56
+ return isinstance (x , Number )
56
57
57
58
58
59
class Options (object ):
Original file line number Diff line number Diff line change
1
+ import sys
2
+ import decimal
1
3
from tests import unittest , OrderedDict
2
4
3
5
import jmespath
@@ -43,3 +45,14 @@ def test_can_compare_strings(self):
43
45
# This is python specific behavior that's not in the official spec
44
46
# yet, but this was regression from 0.9.0 so it's been added back.
45
47
self .assertTrue (jmespath .search ('a < b' , {'a' : '2016' , 'b' : '2017' }))
48
+
49
+ @unittest .skipIf (not hasattr (sys , 'maxint' ), 'Test requires long() type' )
50
+ def test_can_handle_long_ints (self ):
51
+ result = sys .maxint + 1
52
+ self .assertEqual (jmespath .search ('[?a >= `1`].a' , [{'a' : result }]),
53
+ [result ])
54
+
55
+ def test_can_handle_decimals_as_numeric_type (self ):
56
+ result = decimal .Decimal ('3' )
57
+ self .assertEqual (jmespath .search ('[?a >= `1`].a' , [{'a' : result }]),
58
+ [result ])
You can’t perform that action at this time.
0 commit comments