Skip to content

Commit 869fe2d

Browse files
committed
Fix values to work with fnmatchcase
1 parent 42ad0a1 commit 869fe2d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

dpath/segments.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ def match(segments: Path, glob: Glob):
230230

231231
try:
232232
# If search path segment (s) is an int and the current evaluated index (g) is int-like,
233-
# then g is surely a sequence index as well. Convert it to int and compare.
233+
# then g might be a sequence index as well. Try converting it to an int.
234234
if isinstance(s, int) and isinstance(g, str):
235235
return s == int(g)
236236
except:
237-
# Will reach this point if g can't be converted to an int...
238-
pass
237+
# Will reach this point if g can't be converted to an int (e.g. when g is a RegEx pattern).
238+
# In this case convert s to a str so fnmatch can work on it.
239+
s = str(s)
239240

240241
try:
241242
# Let's see if the glob matches. We will turn any kind of

0 commit comments

Comments
 (0)