File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -14981,12 +14981,23 @@ os_get_terminal_size_impl(PyObject *module, int fd)
14981
14981
termsize = PyStructSequence_New ((PyTypeObject * )TerminalSizeType );
14982
14982
if (termsize == NULL )
14983
14983
return NULL ;
14984
- PyStructSequence_SET_ITEM (termsize , 0 , PyLong_FromLong (columns ));
14985
- PyStructSequence_SET_ITEM (termsize , 1 , PyLong_FromLong (lines ));
14986
- if (PyErr_Occurred ()) {
14987
- Py_DECREF (termsize );
14988
- return NULL ;
14989
- }
14984
+
14985
+ int pos = 0 ;
14986
+
14987
+ #define SET_TERMSIZE (CALL ) \
14988
+ do { \
14989
+ PyObject *item = (CALL); \
14990
+ if (item == NULL) { \
14991
+ Py_DECREF(termsize); \
14992
+ return NULL; \
14993
+ } \
14994
+ PyStructSequence_SET_ITEM(termsize, pos++, item); \
14995
+ } while(0)
14996
+
14997
+ SET_TERMSIZE (PyLong_FromLong (columns ));
14998
+ SET_TERMSIZE (PyLong_FromLong (lines ));
14999
+ #undef SET_TERMSIZE
15000
+
14990
15001
return termsize ;
14991
15002
}
14992
15003
#endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
You can’t perform that action at this time.
0 commit comments