Skip to content

Commit 22b6c01

Browse files
authored
Merge pull request #194 from squatched/support-empty-list-in-get
Support Empty List Path In get
2 parents fbdd17a + dc3f5d9 commit 22b6c01

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

dpath/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def get(
167167
If more than one leaf matches the glob, ValueError is raised. If the glob is
168168
not found and a default is not provided, KeyError is raised.
169169
"""
170-
if glob == "/":
170+
if isinstance(glob, str) and glob == "/" or len(glob) == 0:
171171
return obj
172172

173173
globlist = _split_path(glob, separator)

tests/test_get_values.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def test_util_get_root():
1717
ret = dpath.get(x, '/')
1818
assert ret == x
1919

20+
ret = dpath.get(x, [])
21+
assert ret == x
22+
2023

2124
def test_get_explicit_single():
2225
ehash = {

0 commit comments

Comments
 (0)