Skip to content

fix: preserve original skeleton in KeyError when fuzzy format_skeleton finds no match#1275

Open
SAY-5 wants to merge 1 commit into
python-babel:masterfrom
SAY-5:fix/format-skeleton-keyerror-none
Open

fix: preserve original skeleton in KeyError when fuzzy format_skeleton finds no match#1275
SAY-5 wants to merge 1 commit into
python-babel:masterfrom
SAY-5:fix/format-skeleton-keyerror-none

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 25, 2026

When format_skeleton is called with fuzzy=True and match_skeleton finds no close match, it returns None. The subsequent locale.datetime_skeletons[skeleton] lookup then raises KeyError: None, which is confusing since it hides the skeleton that was actually requested.

This change falls back to the original skeleton when match_skeleton returns None, so the error is KeyError: 'G' instead of KeyError: None, consistent with the fuzzy=False behavior.

Fixes #1084.

…n finds no match

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

KeyError raised in format_skeleton when using fuzzy matching

1 participant