You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stevendaprano opened this issue
Mar 26, 2022
· 3 comments
Labels
3.7 (EOL)end of life3.8only security fixes3.9only security fixes3.10only security fixes3.11only security fixesdocsDocumentation in the Doc dirtype-featureA feature request or enhancement
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2022-03-26.22:10:10.212>labels= ['3.7', '3.8', '3.9', '3.10', '3.11', 'type-feature', 'docs']
title='Document the meaning of the number in OverflowError'updated_at=<Date2022-03-26.22:46:01.129>user='https://github.com/stevendaprano'
The error code for 1e+300 ** 2 is ERANGE, from calling libm pow(). Since pow() returns a double, there's no way to indicate an error in the return value. Instead, C errno is set to 0 beforehand and checked for a non-zero error value after the call. If the error code isn't ERANGE, then float.pow() raises ValueError instead of OverflowError. Here's the relevant snippet from float_pow() in Objects/floatobject.c:
/* Now iv and iw are finite, iw is nonzero, and iv is
* positive and not equal to 1.0. We finally allow
* the platform pow to step in and do the rest.
*/
errno = 0;
ix = pow(iv, iw);
_Py_ADJUST_ERANGE1(ix);
if (negate_result)
ix = -ix;
if (errno!=0) {
/* We don't expect any errno value other than ERANGE, but * the range of libm bugs appears unbounded. */PyErr_SetFromErrno(errno==ERANGE ? PyExc_OverflowError :
PyExc_ValueError);
returnNULL;
}
returnPyFloat_FromDouble(ix);
3.7 (EOL)end of life3.8only security fixes3.9only security fixes3.10only security fixes3.11only security fixesdocsDocumentation in the Doc dirtype-featureA feature request or enhancement
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: