Skip to content

Reject negative plural indexes when reading PO files - #1535

Open
Stokesy-dev wants to merge 1 commit into
python-babel:masterfrom
Stokesy-dev:fix/negative-po-plural-index
Open

Stokesy-dev wants to merge 1 commit into
python-babel:masterfrom
Stokesy-dev:fix/negative-po-plural-index

Conversation

@Stokesy-dev

Copy link
Copy Markdown

Fixes #1534.

PO plural indexes start at zero. Reject negative indexes before Python can use them to address the list from the end or raise an unrelated IndexError. Use Babel's existing invalid-file handler so default mode warns and skips the entry, while abort_invalid=True raises PoFileError.

Tests cover -1 and -3 in both modes. Ran the full pytest suite and Ruff on the two changed files.

AI disclosure: OpenAI Codex helped implement and test this change and draft this description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_po raises IndexError for a negative msgstr[N] index, even with abort_invalid=True

1 participant