Message323930
I'm not sure that the pytime.c change in commit a853a8ba7850381d49b284295dd6f0dc491dbe44 is correct:
diff --git a/Python/pytime.c b/Python/pytime.c
index 8979adc219..f3c913226c 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -276,7 +278,6 @@ static int
_PyTime_FromFloatObject(_PyTime_t *t, double value, _PyTime_round_t round,
long unit_to_ns)
{
- double err;
/* volatile avoids optimization changing how numbers are rounded */
volatile double d;
@@ -285,12 +286,11 @@ _PyTime_FromFloatObject(_PyTime_t *t, double value, _PyTime_round_t round,
d *= (double)unit_to_ns;
d = _PyTime_Round(d, round);
- *t = (_PyTime_t)d;
- err = d - (double)*t;
- if (fabs(err) >= 1.0) {
+ if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
_PyTime_overflow();
return -1;
}
+ *t = (_PyTime_t)d;
return 0;
}
I don't think that modifying _Py_InIntegralTypeRange() macro to replace "<=" with "<" is correct, since this bug is very specific to pytime.c, when _Py_InIntegralTypeRange() is used with a double. The PR proposes:
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v < _Py_IntegralTypeMax(type)) |
|
Date |
User |
Action |
Args |
2018-08-23 08:52:43 | vstinner | set | recipients:
+ vstinner, lemburg, mark.dickinson, belopolsky, enedil |
2018-08-23 08:52:43 | vstinner | set | messageid: <1535014363.31.0.56676864532.issue34423@psf.upfronthosting.co.za> |
2018-08-23 08:52:43 | vstinner | link | issue34423 messages |
2018-08-23 08:52:43 | vstinner | create | |
|