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 @@ -13447,12 +13447,23 @@ os_get_terminal_size_impl(PyObject *module, int fd)
1344713447 termsize = PyStructSequence_New ((PyTypeObject * )TerminalSizeType );
1344813448 if (termsize == NULL )
1344913449 return NULL ;
13450- PyStructSequence_SET_ITEM (termsize , 0 , PyLong_FromLong (columns ));
13451- PyStructSequence_SET_ITEM (termsize , 1 , PyLong_FromLong (lines ));
13452- if (PyErr_Occurred ()) {
13453- Py_DECREF (termsize );
13454- return NULL ;
13455- }
13450+
13451+ int pos = 0 ;
13452+
13453+ #define SET_TERMSIZE (CALL ) \
13454+ do { \
13455+ PyObject *item = (CALL); \
13456+ if (item == NULL) { \
13457+ Py_DECREF(termsize); \
13458+ return NULL; \
13459+ } \
13460+ PyStructSequence_SET_ITEM(termsize, pos++, item); \
13461+ } while(0)
13462+
13463+ SET_TERMSIZE (PyLong_FromLong (columns ));
13464+ SET_TERMSIZE (PyLong_FromLong (lines ));
13465+ #undef SET_TERMSIZE
13466+
1345613467 return termsize ;
1345713468}
1345813469#endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
You can’t perform that action at this time.
0 commit comments