Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format_timedelta throws a KeyError for the Portuguese locale #825

Closed
zalzac opened this issue Jan 24, 2022 · 1 comment · Fixed by #827
Closed

format_timedelta throws a KeyError for the Portuguese locale #825

zalzac opened this issue Jan 24, 2022 · 1 comment · Fixed by #827

Comments

@zalzac
Copy link

zalzac commented Jan 24, 2022

Overview Description

format_timedelta throws a KeyError for the Portuguese locale when parsing one hour in short format.

Steps to Reproduce

from datetime import timedelta
from babel.dates import format_timedelta

format_timedelta(timedelta(hours=1), granularity='hour', threshold=100, format='short', locale='pt')

Actual Results

Traceback (most recent call last):
  File "/home/user/miniconda3/envs/py38/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/babel/dates.py", line 952, in format_timedelta
    pattern = patterns[plural_form]
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/babel/localedata.py", line 238, in __getitem__
    orig = val = self._data[key]
KeyError: 'one'

Expected Results

'1 h'

Additional Information

babel version == 2.9.1

@akx
Copy link
Member

akx commented Jan 25, 2022

Thanks for the report! This should be fixed by #827.

@akx akx added this to the Babel 2.10 milestone Jan 25, 2022
akx added a commit that referenced this issue Jan 25, 2022
@akx akx closed this as completed in #827 Jan 25, 2022
akx added a commit that referenced this issue Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants