Index: Python/sysmodule.c =================================================================== --- Python/sysmodule.c (Revision 59248) +++ Python/sysmodule.c (Arbeitskopie) @@ -18,6 +18,7 @@ #include "code.h" #include "frameobject.h" #include "eval.h" +#include #include "osdefs.h" @@ -1045,7 +1046,37 @@ return shortbranch; } +#define SET_FLOAT_CONST(d, key, const) \ + tmp = PyFloat_FromDouble(const); \ + if (tmp == NULL) return NULL; \ + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ + Py_DECREF(tmp) +#define SET_INT_CONST(d, key, const) \ + tmp = PyInt_FromLong(const); \ + if (tmp == NULL) return NULL; \ + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ + Py_DECREF(tmp) + PyObject * +maxfloat(void) +{ + PyObject *d, *tmp; + d = PyDict_New(); + SET_FLOAT_CONST(d, "max", DBL_MAX); + SET_INT_CONST(d, "max_exp", DBL_MAX_EXP); + SET_INT_CONST(d, "max_10_exp", DBL_MAX_10_EXP); + SET_FLOAT_CONST(d, "min", DBL_MIN); + SET_INT_CONST(d, "min_exp", DBL_MIN_EXP); + SET_INT_CONST(d, "min_10_exp", DBL_MIN_10_EXP); + SET_INT_CONST(d, "dig", DBL_DIG); + SET_INT_CONST(d, "mant_dig", DBL_MANT_DIG); + SET_FLOAT_CONST(d, "epsilon", DBL_EPSILON); + SET_INT_CONST(d, "radix", FLT_RADIX); + SET_INT_CONST(d, "rounds", FLT_ROUNDS); + return d; +} + +PyObject * _PySys_Init(void) { PyObject *m, *v, *sysdict; @@ -1169,6 +1200,8 @@ PyInt_FromLong(PyInt_GetMax())); SET_SYS_FROM_STRING("py3kwarning", PyBool_FromLong(Py_Py3kWarningFlag)); + SET_SYS_FROM_STRING("maxfloat", + maxfloat()); #ifdef Py_USING_UNICODE SET_SYS_FROM_STRING("maxunicode", PyInt_FromLong(PyUnicode_GetMax()));