File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 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)
1498114981 termsize = PyStructSequence_New ((PyTypeObject * )TerminalSizeType );
1498214982 if (termsize == NULL )
1498314983 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+
1499015001 return termsize ;
1499115002}
1499215003#endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
You can’t perform that action at this time.
0 commit comments