]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125843: fix `test_curses.test_attributes` on x86-64 macOS (#134252)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Tue, 20 May 2025 09:15:39 +0000 (11:15 +0200)
committerGitHub <noreply@github.com>
Tue, 20 May 2025 09:15:39 +0000 (09:15 +0000)
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

index ab63fdbe45de61a0aefe148254f4242b2c765bbe..2e6ec822e2d5b6785e96d5b66ff216467deb5417 100644 (file)
@@ -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;
     }