Skip to content

Escape literal locale choices when parsing dates - #1368

Open
FanWu-ai wants to merge 1 commit into
arrow-py:masterfrom
FanWu-ai:fix/escape-locale-parser-choices
Open

FanWu-ai wants to merge 1 commit into
arrow-py:masterfrom
FanWu-ai:fix/escape-locale-parser-choices

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 6, 2026

Copy link
Copy Markdown

Pull Request Checklist

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass locally on Python 3.12.14.
  • 🧹 All configured linting checks pass locally.
  • 📚 Updated the helper's docstring for literal matching.
  • ⏩ Code is up-to-date with master.

Description of Changes

Locale month names, day names, and meridians are literal text, but their punctuation is currently interpolated into regular expressions without escaping. For example, Catalan gen. matches genx, leading to a TypeError during date construction; malformed Armenian PM markers can silently produce an AM time.

Escape these choices before joining the alternatives. Add regression coverage for month/day abbreviations, meridians, and alternative-format fallback, while verifying correctly punctuated locale strings still parse.

Validation

  • Untouched upstream: 1,904 tests passed; all four new regression cases then failed
  • Final: 1,908 tests passed, 99.93% coverage, no skips or xfails
  • All 23 configured pre-commit hooks passed, including Flake8, Black and mypy
  • doc8 and the Sphinx warnings-as-errors build passed
  • git diff --check passed
  • Additional validation covered all 7,938 registered locale choices and regex-metacharacter near-matches

Tested on Linux with Python 3.12.14. The hosted Python/OS matrix has not run on this commit yet. This patch was prepared with OpenAI Codex assistance.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 6, 2026 21:52

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