Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 45060:c05ee77b39f2 legacy-trunk
The previous change was causing a segfault after multiple calls to Py_Initialize() and Py_Finalize().
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Wed, 30 Jan 2008 18:58:29 +0000 |
| parents | 9639a73afa47 |
| children | beea73ca2b88 |
line wrap: on
line diff
--- a/Objects/floatobject.c Wed Jan 30 17:21:22 2008 +0000 +++ b/Objects/floatobject.c Wed Jan 30 18:58:29 2008 +0000 @@ -66,7 +66,7 @@ return DBL_MIN; } -static PyTypeObject FloatInfoType = {0}; +static PyTypeObject FloatInfoType = {0, 0, 0, 0, 0, 0}; PyDoc_STRVAR(floatinfo__doc__, "sys.floatinfo\n\ @@ -105,15 +105,9 @@ PyObject * PyFloat_GetInfo(void) { - static PyObject* floatinfo; + PyObject* floatinfo; int pos = 0; - if (floatinfo != NULL) { - Py_INCREF(floatinfo); - return floatinfo; - } - PyStructSequence_InitType(&FloatInfoType, &floatinfo_desc); - floatinfo = PyStructSequence_New(&FloatInfoType); if (floatinfo == NULL) { return NULL; @@ -142,7 +136,6 @@ Py_CLEAR(floatinfo); return NULL; } - return floatinfo; } @@ -1669,6 +1662,9 @@ /* Initialize floating point repr */ _PyFloat_DigitsInit(); #endif + /* Init float info */ + if (FloatInfoType.tp_name == 0) + PyStructSequence_InitType(&FloatInfoType, &floatinfo_desc); } void
