← Winnitude! Search  ·  Reader Mode (1036 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 15 LINKS

py: fix explicit string split limits and empty separators by ac1982 · Pull Request #262 · go-python/gpython

Repository navigation

py: fix explicit string split limits and empty separators - #262


Open
ac1982 wants to merge 1 commit into go-python:main from ac1982:fix/string-split-limits
Open

py: fix explicit string split limits and empty separators #262 ac1982 wants to merge 1 commit into go-python:main from ac1982:fix/string-split-limits

Conversation

ac1982 commented Oct 12, 2026



Copy link Copy Markdown

'a,b,c'.split(',', -1) currently returns [], while omitting maxsplit returns all three fields. An empty separator also succeeds instead of raising ValueError.

Translate negative maxsplit values to Go's unlimited SplitN form, use the Python default of -1, and reject empty separators before splitting. Bound the conversion for large positive limits. Adds direct Go regression cases and interpreter-level Python assertions; seven direct cases fail on the original code.

Validation on Linux/arm64:

  • Full go test -tags=ci -race ./... with Go 1.27.1 passes, including Python test scripts.
  • Full GOTOOLCHAIN=go1.19.13 go test -tags=ci ./... passes.
  • goimports and diff whitespace checks pass.
  • Standalone vet and Staticcheck 2026.2.1 report existing diagnostics (unkeyed literals/unreachable code and an unused assignment); their output is identical on clean upstream 444ae5e . Historical Staticcheck 2022.1 and other OS/architecture jobs were not run.

Contributor registration is pending in go-python/license#24 . AI-assisted implementation and validation.

py: fix explicit string split limits and empty separators fa1e212 Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

1 participant