Skip to content

Commit 51bb943

Browse files
committed
Better type check
1 parent db94e23 commit 51bb943

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

dpath/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import MutableMapping
1+
from collections.abc import MutableMapping, Sized
22
from collections.abc import MutableSequence
33
from dpath import options
44
from dpath.exceptions import InvalidKeyName
@@ -286,13 +286,13 @@ def are_both_mutable(o1, o2):
286286
return False
287287

288288
def merger(dst, src, _segments=()):
289-
if not isinstance(dst, dict) or not isinstance(src, dict):
290-
raise ValueError("Merger function supports dict-like objects only")
291-
292289
for key, found in dpath.segments.kvs(src):
293290
# Our current path in the source.
294291
segments = _segments + (key,)
295292

293+
if not isinstance(key, Sized):
294+
raise ValueError("Merger function supports dict-like objects only")
295+
296296
if len(key) == 0 and not options.ALLOW_EMPTY_STRING_KEYS:
297297
raise InvalidKeyName("Empty string keys not allowed without "
298298
"dpath.options.ALLOW_EMPTY_STRING_KEYS=True: "

0 commit comments

Comments
 (0)