From e007e62ba7403575611145aa2e39900b5f4bc6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 20 May 2025 11:15:39 +0200 Subject: [PATCH] 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. --- Modules/_cursesmodule.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ab63fdbe45d..2e6ec822e2d 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; }