Repository navigation
Reject repeated numbers in slice components - #387
Open
KennyMcSimpson wants to merge 1 commit into
Open
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The slice parser currently accepts multiple numbers in the same component and silently keeps only the last one. For example,
jmespath.search('[0:1 3]', list(range(6)))returns[0, 1, 2], treating the expression as[0:3].[0:1-2]and[::1 2]are accepted similarly.The slice grammar permits at most one number in each component. Reject a second number through the existing syntax-error path instead of overwriting the component. Checking against
Nonealso correctly rejects repeated numbers when the previous number is zero.Add eight invalid-syntax compliance cases covering repeated end/step values, signed values, zero values, and both field and root slices. Add valid whitespace and zero-endpoint controls, and update the changelog.
Validation on Windows / Python 3.13:
python -m tox -e py313: 1001 passed, 1 skipped.ParseErrorat the second number.Other Python versions and operating systems are left to CI. This contribution was prepared with AI assistance.