Skip to content

ALLOW_EMPTY_STRING_KEYS doesn't work when skip=True for dpath.util.get #82

Description

@srids

facing this issue :

import dpath
dpath.options.ALLOW_EMPTY_STRING_KEYS=True
tdict = {'': 'fefa1c8e-9c9f-4da4-8964-a7d93274c101'}
dpath.util.get(tdict, '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 103, in get
    for item in search(obj, glob, yielded=True, separator=separator):
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 143, in _search_yielded
    globlist = __safe_path__(glob, separator)
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 25, in __safe_path__
    key = elem[0]
IndexError: string index out of range

or with a similar test as

import dpath
dpath.options.ALLOW_EMPTY_STRING_KEYS=True
tdict = {
    "Empty": {
        "": {
            "Key": ""
        }
    }
}
dpath.util.get(tdict, 'Empty//Key')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 103, in get
    for item in search(obj, glob, yielded=True, separator=separator):
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 143, in _search_yielded
    globlist = __safe_path__(glob, separator)
  File "/usr/local/lib/python3.6/site-packages/dpath/util.py", line 25, in __safe_path__
    key = elem[0]
IndexError: string index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions