From: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Date: Tue, 20 May 2025 09:15:39 +0000 (+0200) Subject: gh-125843: fix `test_curses.test_attributes` on x86-64 macOS (#134252) X-Git-Tag: v3.15.0a1~1640 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e007e62ba7403575611145aa2e39900b5f4bc6bd;p=thirdparty%2FPython%2Fcpython.git gh-125843: fix `test_curses.test_attributes` on x86-64 macOS (#134252) While some `libcurses` functions are meant to return OK on success, this is not always the case for all implementations. As such, we relax the checks on the return values and allow any non-ERR value to be considered equivalent to OK. --- diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ab63fdbe45de..2e6ec822e2d5 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -392,9 +392,9 @@ _PyCursesStatefulCheckFunction(PyObject *module, */ /* - * Return None if 'code' is OK. Otherwise, set an exception - * using curses_set_error() and the remaining arguments, and - * return NULL. + * Return None if 'code' is different from ERR (implementation-defined). + * Otherwise, set an exception using curses_set_error() and the remaining + * arguments, and return NULL. */ static PyObject * curses_check_err(PyObject *module, int code, @@ -402,7 +402,6 @@ curses_check_err(PyObject *module, int code, const char *python_funcname) { if (code != ERR) { - assert(code == OK); Py_RETURN_NONE; } curses_set_error(module, curses_funcname, python_funcname); @@ -416,7 +415,6 @@ curses_window_check_err(PyCursesWindowObject *win, int code, const char *python_funcname) { if (code != ERR) { - assert(code == OK); Py_RETURN_NONE; } curses_window_set_error(win, curses_funcname, python_funcname); @@ -1580,7 +1578,7 @@ _curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, win = derwin(self->win,nlines,ncols,begin_y,begin_x); if (win == NULL) { - curses_window_set_error(self, "derwin", NULL); + curses_window_set_null_error(self, "derwin", NULL); return NULL; }