-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled None in jsonpath.Slice
#82
Comments
I'm experiencing the same issue. Pip installed from github/master. Python 3.9.1. Possibly second problem (that might be related/close)?: >>> jsonpath_rw.parse("list[*]").find({"list": None})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 229, in find
return [submatch
File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 232, in <listcomp>
for submatch in self.right.find(subdata)]
File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 546, in find
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in xrange(0, len(datum.value))]
TypeError: object of type 'NoneType' has no len()
>>> jsonpath_rw.parse("list[*]").find({"list": 1})
[DatumInContext(value=1, path=<jsonpath_rw.jsonpath.Index object at 0x7f1cb1d6a3d0>, context=DatumInContext(value=[1], path=Fields('list'), context=DatumInContext(value={'list': 1}, path=This(), context=None)))]
>>> jsonpath_rw.parse("list[*]").find({"list": "foo"})
[DatumInContext(value='foo', path=<jsonpath_rw.jsonpath.Index object at 0x7f17f674d1f0>, context=DatumInContext(value=['foo'], path=Fields('list'), context=DatumInContext(value={'list': 'foo'}, path=This(), context=None)))] The array-syntax shouldn't match an int or string (nor other types)? This issue (and the referenced PR) is fairly old though. Is this library alive and well? |
Discussion regarding the health of this library #73 |
When specifying a json path that contains a
[*]
, if the value isNone
then aTypeError
is raises.Expected behavior
No exception is raised, and an empty result set is returned.
Minimal reproduction of the issue
Version
tested against
python3.6
andjsonpath_rw==1.4.0
edit: this seems to be fixed by #77, but I can't find the corresponding issue
The text was updated successfully, but these errors were encountered: