Repository navigation
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.
'abcabc'.find('a', -3)and.count('a', -3)panic on negative Go slice bounds. Negative end indices are treated as the string's full length, and empty substring searches can match even when start is past the end or the requested interval is reversed.Share boundary normalization between find and count: translate negative indices relative to the Unicode character length, clamp overly negative bounds and overly large ends, and return no match for reversed or out-of-range starts. The actual search/count algorithms remain unchanged.
Adds 28 direct cases with expectations independently obtained from CPython, plus six Python interpreter assertions covering ASCII, Unicode, empty strings and empty patterns. Eighteen direct cases fail before the fix, including panics.
Validation: full
go test -tags=ci -race ./...on Go 1.27.1 and fullGOTOOLCHAIN=go1.19.13 go test -tags=ci ./...pass on Linux/arm64. goimports/diff checks pass. Standalone vet and Staticcheck 2026.2.1 diagnostics are byte-identical to clean upstream 444ae5e (existing unkeyed literals, unreachable code and an unused assignment). Historical Staticcheck and other OS/architecture jobs were not run.Contributor registration: go-python/license#24. AI-assisted implementation and validation.