Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a bug in :func:`termios.tcsetwinsize` where passing a sequence that
raises an exception in ``__getitem__`` would cause a :exc:`SystemError`
instead of propagating the original exception.
13 changes: 9 additions & 4 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,19 +500,24 @@ termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz)
PyObject *tmp_item;
long winsz_0, winsz_1;
tmp_item = PySequence_GetItem(winsz, 0);
if (tmp_item == NULL) {
return NULL;
}
winsz_0 = PyLong_AsLong(tmp_item);
Py_DECREF(tmp_item);
if (winsz_0 == -1 && PyErr_Occurred()) {
Py_XDECREF(tmp_item);
return NULL;
}
Py_XDECREF(tmp_item);
tmp_item = PySequence_GetItem(winsz, 1);
if (tmp_item == NULL) {
return NULL;
}
winsz_1 = PyLong_AsLong(tmp_item);
Py_DECREF(tmp_item);
if (winsz_1 == -1 && PyErr_Occurred()) {
Py_XDECREF(tmp_item);
return NULL;
}
Py_XDECREF(tmp_item);


termiosmodulestate *state = PyModule_GetState(module);

Expand Down
Loading