Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-97786: Fix compiler warnings in pytime.c #101826

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

Merged
merged 3 commits into from
Feb 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add note on nans; remove unnecessary asserts
  • Loading branch information
mdickinson committed Feb 12, 2023
commit c381e4c1170fe02efcde3a7d61719e4aecbf741c
6 changes: 3 additions & 3 deletions 6 Python/pytime.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@ pytime_double_to_denominator(double d, time_t *sec, long *numerator,
assumption that time_t is a two's complement integer type with no trap
representation, and that `PY_TIME_T_MIN` is within the representable
range of a C double.

Note: we want the `if` condition below to be true for NaNs; therefore,
resist any temptation to simplify by applying De Morgan's laws.
*/
assert(fmod(intpart, 1.0) == 0.0);
if (!((double)PY_TIME_T_MIN <= intpart && intpart < -(double)PY_TIME_T_MIN)) {
gpshead marked this conversation as resolved.
Show resolved Hide resolved
pytime_time_t_overflow();
return -1;
Expand Down Expand Up @@ -369,7 +371,6 @@ _PyTime_ObjectToTime_t(PyObject *obj, time_t *sec, _PyTime_round_t round)
(void)modf(d, &intpart);

/* See comments in pytime_double_to_denominator */
assert(fmod(intpart, 1.0) == 0.0);
if (!((double)PY_TIME_T_MIN <= intpart && intpart < -(double)PY_TIME_T_MIN)) {
pytime_time_t_overflow();
return -1;
Expand Down Expand Up @@ -537,7 +538,6 @@ pytime_from_double(_PyTime_t *tp, double value, _PyTime_round_t round,
d = pytime_round(d, round);

/* See comments in pytime_double_to_denominator */
assert(fmod(d, 1.0) == 0.0);
if (!((double)_PyTime_MIN <= d && d < -(double)_PyTime_MIN)) {
pytime_time_t_overflow();
return -1;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.