Skip to content

Respect custom separators for C/POSIX locale aliases - #1360

Open
PDGGK wants to merge 1 commit into
python-babel:masterfrom
PDGGK:fix-posix-alias-separator
Open

PDGGK wants to merge 1 commit into
python-babel:masterfrom
PDGGK:fix-posix-alias-separator

Conversation

@PDGGK

@PDGGK PDGGK commented Oct 3, 2026

Copy link
Copy Markdown

Summary

Respect sep when normalizing the C/POSIX locale aliases.

Locale.parse("C", sep="-") and Locale.parse("POSIX", sep="-") currently fail because alias normalization builds en_US_POSIX, which is then parsed using -. The explicit canonical input Locale.parse("en-US-POSIX", sep="-") succeeds.

Build the alias with sep.join(("en", "US", "POSIX")) instead. This preserves the default underscore behavior and allows the supported hyphen separator. Public Locale.negotiate(["C"], ["C"], sep="-") follows the repaired path too.

This is a small follow-up to #1340. It does not change encoding/modifier handling or make C/POSIX and their canonical spellings interchangeable availability entries during negotiation.

Validation

Linux, CPython 3.12.14:

  • 16 focused cases pass; original source and production-only revert reproduce 9 failures with 7 passing controls.
  • Full suite with normal doctest collection: 7,846 passed, 7 skipped, 2 expected failures.
  • Pinned Ruff and all pre-commit hooks pass.
  • Source distribution/wheel builds and clean-wheel parsing, negotiation, and formatting smoke checks pass.

The skips and expected failures are pre-existing. Windows, macOS, other supported Python versions, and hosted CI have not been run for this patch.

AI assistance: implementation, tests, and this description were prepared with OpenAI assistance.

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.

1 participant