8000 Unhandled None in `jsonpath.Slice` · Issue #82 · kennknowles/python-jsonpath-rw · GitHub
[go: up one dir, main page]

Skip to content
Unhandled None in jsonpath.Slice #82
Open
@jacobbogdanov

Description

@jacobbogdanov

When specifying a json path that contains a [*], if the value is None then a TypeError is raises.

Expected behavior

No exception is raised, and an empty result set is returned.

Minimal reproduction of the issue

>>> import jsonpath_rw
>>> d = {"key": None}
>>> p = jsonpath_rw.parse('$.key.[*].value')
>>> p.find(d)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    p.find(d)
  File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py",
 line 226, in find
    for subdata in self.left.find(datum)
  File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py",
 line 226, in find
    for subdata in self.left.find(datum)
  File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py",
 line 228, in <listcomp>
    for submatch in self.right.find(subdata)]
  File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py",
 line 494, 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()

Version

tested against python3.6 and jsonpath_rw==1.4.0

edit: this seems to be fixed by #77, but I can't find the corresponding issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0