標準ライブラリには、次のモジュールがありますerrno
。
このモジュールは、標準の errno システム シンボルを利用できるようにします。各シンボルの値は、対応する整数値です。名前と説明は linux/include/errno.h から借用したもので、かなり包括的なはずです。
/usr/include/linux/errno.h
が含まれ/usr/include/asm/errno.h
ています/usr/include/asm-generic/errno-base.h
。
me@my_pc:~$ cat /usr/include/asm-generic/errno-base.h | grep 34
#define ERANGE 34 /* Math result not representable */
これで、34 エラー コードが ERANGE を表していることがわかりました。
1e4**100
Object/floatobject.cのfloat_pow
関数で処理されます。その関数の部分的なソース コード:
static PyObject *
float_pow(PyObject *v, PyObject *w, PyObject *z)
{
// 107 lines omitted
if (errno != 0) {
/* We do not expect any errno value other than ERANGE, but
* the range of libm bugs appears unbounded.
*/
PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError :
PyExc_ValueError);
return NULL;
}
return PyFloat_FromDouble(ix);
}
そのため、1e4**100
ERANGE エラーが発生し (結果としてPyExc_OverflowError
)、上位レベルのOverflowError
例外が発生します。