Message407800
| Author |
vstinner |
| Recipients |
ZackerySpytz, hongweipeng, martin.panter, p-ganssle, pitrou, vstinner |
| Date |
2021年12月06日.13:26:08 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1638797168.54.0.162356056183.issue33632@roundup.psfhosted.org> |
| In-reply-to |
| Content |
> I think PR https://github.com/python/cpython/pull/28674 has resolved this issue.
You're right.
_threadmodule.c now uses _PyDeadline_Init() which calls _PyTime_Add(), and _PyTime_Add() prevents integer overflows; Extract of its implementation:
// Compute t1 + t2. Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
static inline int
pytime_add(_PyTime_t *t1, _PyTime_t t2)
{
if (t2 > 0 && *t1 > _PyTime_MAX - t2) {
*t1 = _PyTime_MAX;
return -1;
}
else if (t2 < 0 && *t1 < _PyTime_MIN - t2) {
*t1 = _PyTime_MIN;
return -1;
}
else {
*t1 += t2;
return 0;
}
} |
|