bpo-39277, pytime: Fix overflow check on double to int cast#17933
bpo-39277, pytime: Fix overflow check on double to int cast#17933vstinner wants to merge 1 commit into
Conversation
Fix time.sleep() to properly detect integer overflow when converting a floating-point number of seconds to an integer.
|
A safe way to do what you want is: (1) Take the integral part of the double Computing The reason that step (2) is safe is that, making the fairly safe assumption of 2s complement (no trap representation, etc., etc.) for signed integers, |
Sorry, something went wrong.
mdickinson
left a comment
There was a problem hiding this comment.
This isn't the right way to check for convertibility; see the other comments I made on the PR.
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be put in the comfy chair! |
Sorry, something went wrong.
|
I failed finding time to finish the PR. I prefer to abandon it. |
Sorry, something went wrong.
Fix time.sleep() to properly detect integer overflow when converting
a floating-point number of seconds to an integer.
https://bugs.python.org/issue39277