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

Avoid coercing nan or inf to int in fast_real. #14

Merged
merged 2 commits into from Jun 29, 2018

Conversation

SethMMorton
Copy link
Owner

@SethMMorton SethMMorton commented Jun 29, 2018

If a very large float was given to fast_real and coerce was set to True,
then it would be blindly converted to an int even if the value was inf.
This created an OverflowError which is not desirable.

The solution is to explicitly check for inf and nan before attempting the
integer conversion.

This will fix #13.

If a very large float was given to fast_real and coerce was set to True,
then it would be blindly converted to an int even if the value was inf.
This created an OverflowError which is not desirable.

The solution is to explicitly check for inf and nan before attempting the
integer conversion.
The tests make sure inf is returned instead of an OverflowError.
@codecov
Copy link

codecov bot commented Jun 29, 2018

Codecov Report

Merging #14 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
+ Coverage   92.45%   92.47%   +0.02%     
==========================================
  Files          17       17              
  Lines         848      851       +3     
  Branches      129      129              
==========================================
+ Hits          784      787       +3     
  Misses         31       31              
  Partials       33       33
Impacted Files Coverage Δ
src/convert_string_to_number.c 92.68% <100%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c32fc81...9767ed7. Read the comment docs.

@SethMMorton SethMMorton merged commit eb5e2f6 into master Jun 29, 2018
@SethMMorton SethMMorton deleted the 13-overflowerror-fast-real-large-float branch June 29, 2018 07:00
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.

OverflowError when raise_on_invalid=True
1 participant