File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 2121- Raise a ` JSONPathSyntaxError ` for empty selector segments.
2222- Raise a ` JSONPathIndexError ` if an index selector is out of range.
2323- Raise a ` JSONPathSyntaxError ` for too many colons in a slice selector.
24+ - Raise a ` JSONPathIndexError ` if a slice selector argument is out of range.
2425
2526## Version 0.4.0
2627
Original file line number Diff line number Diff line change @@ -204,8 +204,8 @@ def __init__(
204204 stop : Optional [int ] = None ,
205205 step : Optional [int ] = None ,
206206 ) -> None :
207- # TODO: raise if start, stop or step are out of range
208207 super ().__init__ (env = env , token = token )
208+ self ._check_range (start , stop , step )
209209 self .slice = slice (start , stop , step )
210210
211211 def __str__ (self ) -> str :
@@ -214,6 +214,13 @@ def __str__(self) -> str:
214214 step = self .slice .step if self .slice .step is not None else "1"
215215 return f"[{ start } :{ stop } :{ step } ]"
216216
217+ def _check_range (self , * indices : Optional [int ]) -> None :
218+ for i in indices :
219+ if i is not None and (
220+ i < self .env .min_int_index or i > self .env .max_int_index
221+ ):
222+ raise JSONPathIndexError ("index out of range" )
223+
217224 def _normalized_index (self , obj : Sequence [object ], index : int ) -> int :
218225 if index < 0 and len (obj ) >= abs (index ):
219226 return len (obj ) + index
You can’t perform that action at this time.
0 commit comments