diff --git a/gjson/__init__.py b/gjson/__init__.py index 9a48177..126d6e6 100644 --- a/gjson/__init__.py +++ b/gjson/__init__.py @@ -572,10 +572,13 @@ def not_match_op(obj_a: Any, obj_b: Any) -> bool: return re.match(obj_b, obj_a) is None oper = not_match_op - if key: - ret = [i for i in obj if key in i and oper(i[key], value)] - else: # Query on an array of non-objects, match them directly - ret = [i for i in obj if oper(i, value)] + try: + if key: + ret = [i for i in obj if key in i and oper(i[key], value)] + else: # Query on an array of non-objects, match them directly + ret = [i for i in obj if oper(i, value)] + except TypeError: + ret = [] if all_items: return ret diff --git a/tests/unit/test_init.py b/tests/unit/test_init.py index fa4e887..6817c40 100644 --- a/tests/unit/test_init.py +++ b/tests/unit/test_init.py @@ -153,6 +153,7 @@ def setup_method(self): ('friends.#(first!%"D*").last', 'Craig'), ('friends.#(first!%"D???").last', 'Craig'), ('friends.#(%0)#', []), + ('friends.#(>40)#', []), ('children.#(!%"*a*")', 'Alex'), ('children.#(%"*a*")#', ['Sara', 'Jack']), # Nested queries (TODO)