Fix ValueError converting negative integers to cardinal in pl, cs, sk#671
Open
santhreal wants to merge 1 commit into
Open
Fix ValueError converting negative integers to cardinal in pl, cs, sk#671santhreal wants to merge 1 commit into
santhreal wants to merge 1 commit into
Conversation
Num2Word_PL/CS/SK.to_cardinal passed the value straight to splitbyx without stripping the sign, so any negative integer (e.g. num2words(-5, lang='pl')) raised ValueError from get_digits on the '-' character. Negatives in (-1, 0) such as -0.5 also silently lost their sign. Handle the leading minus once at the top of to_cardinal, matching the base implementation and the other languages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Num2Word_PL/CS/SK.to_cardinalpasses the value straight tosplitbyxwithout stripping the sign, so any negative integer raisesValueErrorfromget_digitson the-:cs and sk crash the same way, and negatives in (-1, 0) such as
-0.5silently lost their sign. The base implementation and the other languages already handle this. Fixed by stripping the leading minus once at the top ofto_cardinaland prependingnegword, which covers both integer and decimal negatives.Closes #362, closes #71. Open PR #646 fixes negative decimals for these languages, but its pl/cs/sk changes only touch the decimal branch, so the integer crash above remains; this handles both at one place.