File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,18 @@ PyFloat_GetInfo(void)
101101 return NULL ;
102102 }
103103
104- #define SetIntFlag (flag ) \
105- PyStructSequence_SET_ITEM(floatinfo, pos++, PyLong_FromLong(flag))
106- #define SetDblFlag (flag ) \
107- PyStructSequence_SET_ITEM(floatinfo, pos++, PyFloat_FromDouble(flag))
104+ #define SetFlag (CALL ) \
105+ do { \
106+ PyObject *flag = (CALL); \
107+ if (flag == NULL) { \
108+ Py_CLEAR(floatinfo); \
109+ return NULL; \
110+ } \
111+ PyStructSequence_SET_ITEM(floatinfo, pos++, flag); \
112+ } while (0)
113+
114+ #define SetIntFlag (FLAG ) SetFlag(PyLong_FromLong((FLAG)))
115+ #define SetDblFlag (FLAG ) SetFlag(PyFloat_FromDouble((FLAG)))
108116
109117 SetDblFlag (DBL_MAX );
110118 SetIntFlag (DBL_MAX_EXP );
@@ -119,11 +127,8 @@ PyFloat_GetInfo(void)
119127 SetIntFlag (FLT_ROUNDS );
120128#undef SetIntFlag
121129#undef SetDblFlag
130+ #undef SetFlag
122131
123- if (PyErr_Occurred ()) {
124- Py_CLEAR (floatinfo );
125- return NULL ;
126- }
127132 return floatinfo ;
128133}
129134
You can’t perform that action at this time.
0 commit comments