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 @@ -13447,12 +13447,23 @@ os_get_terminal_size_impl(PyObject *module, int fd)
13447
13447
termsize = PyStructSequence_New ((PyTypeObject * )TerminalSizeType );
13448
13448
if (termsize == NULL )
13449
13449
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
+
13456
13467
return termsize ;
13457
13468
}
13458
13469
#endif /* defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL) */
You can’t perform that action at this time.
0 commit comments