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+
190.9.2
210=====
311
Original file line number Diff line number Diff line change 22
33from jmespath import functions
44from jmespath .compat import string_type
5+ from numbers import Number
56
67
78def _equals (x , y ):
@@ -52,7 +53,7 @@ def _is_actual_number(x):
5253 # True
5354 if x is True or x is False :
5455 return False
55- return isinstance (x , ( float , int ) )
56+ return isinstance (x , Number )
5657
5758
5859class Options (object ):
Original file line number Diff line number Diff line change 1+ import sys
2+ import decimal
13from tests import unittest , OrderedDict
24
35import jmespath
@@ -43,3 +45,14 @@ def test_can_compare_strings(self):
4345 # This is python specific behavior that's not in the official spec
4446 # yet, but this was regression from 0.9.0 so it's been added back.
4547 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