https://github.com/python/cpython/commit/e007e62ba7403575611145aa2e39900b5f4bc6bd
commit: e007e62ba7403575611145aa2e39900b5f4bc6bd
branch: main
author: Bénédikt Tran <10796600+picn...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-05-20T09:15:39Z
summary:

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.

files:
M Modules/_cursesmodule.c

diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index ab63fdbe45de61..2e6ec822e2d5b6 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;
     }
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to