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 @@ -14340,12 +14340,23 @@ os_get_terminal_size_impl(PyObject *module, int fd)
1434014340 termsize = PyStructSequence_New ((PyTypeObject * )TerminalSizeType );
1434114341 if (termsize == NULL )
1434214342 return NULL ;
14343- PyStructSequence_SET_ITEM (termsize , 0 , PyLong_FromLong (columns ));
14344- PyStructSequence_SET_ITEM (termsize , 1 , PyLong_FromLong (lines ));
14345- if (PyErr_Occurred ()) {
14346- Py_DECREF (termsize );
14347- return NULL ;
14348- }
14343+
14344+ int pos = 0 ;
14345+
14346+ #define SET_TERMSIZE (CALL ) \
14347+ do { \
14348+ PyObject *item = (CALL); \
14349+ if (item == NULL) { \
14350+ Py_DECREF(termsize); \
14351+ return NULL; \
14352+ } \
14353+ PyStructSequence_SET_ITEM(termsize, pos++, item); \
14354+ } while(0)
14355+
14356+ SET_TERMSIZE (PyLong_FromLong (columns ));
14357+ SET_TERMSIZE (PyLong_FromLong (lines ));
14358+ #undef SET_TERMSIZE
14359+
1434914360 return termsize ;
1435014361}
1435114362#endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
You can’t perform that action at this time.
0 commit comments