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

String inputs fail conversion for some languages #508

Closed
noahw3 opened this issue Mar 23, 2023 · 0 comments · Fixed by #518
Closed

String inputs fail conversion for some languages #508

noahw3 opened this issue Mar 23, 2023 · 0 comments · Fixed by #518

Comments

@noahw3
Copy link

noahw3 commented Mar 23, 2023

Expected Behaviour

When passing in a string parameter, it's expected to be handled the same as if an integer parameter was passed.

Actual Behaviour

Because the input gets turned into a Decimal in init if it's a string, this causes failures in any language implementation that assumes the input will be an integer.

Specifically I ran into an issue with the Italian converter - it attempts to perform arithmetic on the input, and then use those results to index the word arrays. However, because those arithmetic results are Decimal and not int, it throws an error.

TypeError: list indices must be integers or slices, not decimal.Decimal

I haven't tested any other languages, but they may have a similar problem. Notably this issue doesn't exist for the en implementation.

Steps to reproduce

Pass in any string input to the Italian converter.

num2words.num2words(str(34234), lang='it', to='cardinal')

Quuxplusone added a commit to Quuxplusone/num2words that referenced this issue May 1, 2023
Quuxplusone added a commit to Quuxplusone/num2words that referenced this issue May 3, 2023
mrodriguezg1991 added a commit that referenced this issue May 24, 2023
Fix #508: Handle string inputs in Italian `to_ordinal`
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 a pull request may close this issue.

1 participant