FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-36589: Fix the error handling in curses.update_lines_cols() by ZackerySpytz · Pull Request #12766 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The :func:`curses.update_lines_cols` function now returns ``None`` instead
of ``1`` on success.
29 changes: 21 additions & 8 deletions Modules/_cursesmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3837,15 +3837,18 @@ update_lines_cols(void)
}

/*[clinic input]
_curses.update_lines_cols -> int
_curses.update_lines_cols

[clinic start generated code]*/

static int
static PyObject *
_curses_update_lines_cols_impl(PyObject *module)
/*[clinic end generated code: output=0345e7f072ea711a input=3a87760f7d5197f0]*/
/*[clinic end generated code: output=423f2b1e63ed0f75 input=5f065ab7a28a5d90]*/
{
return update_lines_cols();
if (!update_lines_cols()) {
return NULL;
}
Py_RETURN_NONE;
}

#endif
Expand Down Expand Up @@ -3929,8 +3932,10 @@ _curses_resizeterm_impl(PyObject *module, int nlines, int ncols)
result = PyCursesCheckERR(resizeterm(nlines, ncols), "resizeterm");
if (!result)
return NULL;
if (!update_lines_cols())
if (!update_lines_cols()) {
Py_DECREF(result);
return NULL;
}
return result;
}

Expand Down Expand Up @@ -3966,8 +3971,10 @@ _curses_resize_term_impl(PyObject *module, int nlines, int ncols)
result = PyCursesCheckERR(resize_term(nlines, ncols), "resize_term");
if (!result)
return NULL;
if (!update_lines_cols())
if (!update_lines_cols()) {
Py_DECREF(result);
return NULL;
}
return result;
}
#endif /* HAVE_CURSES_RESIZE_TERM */
Expand Down Expand Up @@ -4038,12 +4045,18 @@ _curses_start_color_impl(PyObject *module)
c = PyLong_FromLong((long) COLORS);
if (c == NULL)
return NULL;
PyDict_SetItemString(ModDict, "COLORS", c);
if (PyDict_SetItemString(ModDict, "COLORS", c) < 0) {
Py_DECREF(c);
return NULL;
}
Py_DECREF(c);
cp = PyLong_FromLong((long) COLOR_PAIRS);
if (cp == NULL)
return NULL;
PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp);
if (PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp) < 0) {
Py_DECREF(cp);
return NULL;
}
Py_DECREF(cp);
Py_RETURN_NONE;
} else {
Expand Down
16 changes: 3 additions & 13 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


Back | FazBrowse Home | New Git URL