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

Fix Coerce validator to catch decimal.InvalidOperation #291

Merged
merged 1 commit into from
May 31, 2017
Merged

Fix Coerce validator to catch decimal.InvalidOperation #291

merged 1 commit into from
May 31, 2017

Conversation

geerk
Copy link
Contributor

@geerk geerk commented May 31, 2017

For some reason Python std lib has inconsistency in handling invalid values for numeric types:

>>> float('abc')
ValueError: could not convert string to float: abc
>>> int('abc')
ValueError: invalid literal for int() with base 10: 'abc'
>>> Fraction('abc')
ValueError: Invalid literal for Fraction: 'abc'
>>> Decimal('abc')
decimal.InvalidOperation: Invalid literal for Decimal: 'abc'

So this PR is to add InvalidOperation exception for Decimal type when using Coerce validator.

@coveralls
Copy link

coveralls commented May 31, 2017

Coverage Status

Coverage remained the same at 95.309% when pulling a30155c on geerk:master into 85b96b3 on alecthomas:master.

@alecthomas alecthomas merged commit 2392366 into alecthomas:master May 31, 2017
@geerk
Copy link
Contributor Author

geerk commented Jun 1, 2017

@alecthomas Thanks!

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.

3 participants