@@ -92,7 +92,7 @@ def get(obj, segments: Path):
9292 if leaf (current ):
9393 raise PathNotFound (f"Path: { segments } [{ i } ]" )
9494
95- if isinstance (current , Sequence ) and isinstance (segment , ( str , bytes )) and segment .isdigit ():
95+ if isinstance (current , Sequence ) and isinstance (segment , str ) and segment .isdecimal ():
9696 segment = int (segment )
9797
9898 current = current [segment ]
@@ -314,7 +314,7 @@ def _default_creator(
314314 else :
315315 segment_next = None
316316
317- if isinstance (segment_next , int ) or segment_next . isdigit ( ):
317+ if isinstance (segment_next , int ) or ( isinstance ( segment_next , str ) and segment_next . isdecimal () ):
318318 current [segment ] = []
319319 else :
320320 current [segment ] = {}
@@ -342,7 +342,7 @@ def set(
342342 for (i , segment ) in enumerate (segments [:- 1 ]):
343343
344344 # If segment is non-int but supposed to be a sequence index
345- if isinstance (segment , ( str , bytes )) and isinstance (current , Sequence ) and segment .isdigit ():
345+ if isinstance (segment , str ) and isinstance (current , Sequence ) and segment .isdecimal ():
346346 segment = int (segment )
347347
348348 try :
@@ -364,7 +364,7 @@ def set(
364364 last_segment = segments [- 1 ]
365365
366366 # Resolve ambiguity of last segment
367- if isinstance (last_segment , ( str , bytes )) and isinstance (current , Sequence ) and last_segment .isdigit ():
367+ if isinstance (last_segment , str ) and isinstance (current , Sequence ) and last_segment .isdecimal ():
368368 last_segment = int (last_segment )
369369
370370 if isinstance (last_segment , int ):
0 commit comments