Eryk Sun added the comment:
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
New submission from Steven D'Aprano :
OverflowError sometimes (but not always) includes some sort of numeric code:
>>> 1e+300 ** 2
Traceback (most recent call last):
File "", line 1, in
OverflowError: (34, 'Numerical result out of range')
but the meaning of the 34 is not documented: