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 @@ -98,10 +98,18 @@ PyFloat_GetInfo(void)
9898 return NULL ;
9999 }
100100
101- #define SetIntFlag (flag ) \
102- PyStructSequence_SET_ITEM(floatinfo, pos++, PyLong_FromLong(flag))
103- #define SetDblFlag (flag ) \
104- PyStructSequence_SET_ITEM(floatinfo, pos++, PyFloat_FromDouble(flag))
101+ #define SetFlag (CALL ) \
102+ do { \
103+ PyObject *flag = (CALL); \
104+ if (flag == NULL) { \
105+ Py_CLEAR(floatinfo); \
106+ return NULL; \
107+ } \
108+ PyStructSequence_SET_ITEM(floatinfo, pos++, flag); \
109+ } while (0)
110+
111+ #define SetIntFlag (FLAG ) SetFlag(PyLong_FromLong((FLAG)))
112+ #define SetDblFlag (FLAG ) SetFlag(PyFloat_FromDouble((FLAG)))
105113
106114 SetDblFlag (DBL_MAX );
107115 SetIntFlag (DBL_MAX_EXP );
@@ -116,11 +124,8 @@ PyFloat_GetInfo(void)
116124 SetIntFlag (FLT_ROUNDS );
117125#undef SetIntFlag
118126#undef SetDblFlag
127+ #undef SetFlag
119128
120- if (PyErr_Occurred ()) {
121- Py_CLEAR (floatinfo );
122- return NULL ;
123- }
124129 return floatinfo ;
125130}
126131
You can’t perform that action at this time.
0 commit comments