Skip to content

Commit e007e62

Browse files
authored
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.
1 parent 28625d4 commit e007e62

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Modules/_cursesmodule.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,16 @@ _PyCursesStatefulCheckFunction(PyObject *module,
392392
*/
393393

394394
/*
395-
* Return None if 'code' is OK. Otherwise, set an exception
396-
* using curses_set_error() and the remaining arguments, and
397-
* return NULL.
395+
* Return None if 'code' is different from ERR (implementation-defined).
396+
* Otherwise, set an exception using curses_set_error() and the remaining
397+
* arguments, and return NULL.
398398
*/
399399
static PyObject *
400400
curses_check_err(PyObject *module, int code,
401401
const char *curses_funcname,
402402
const char *python_funcname)
403403
{
404404
if (code != ERR) {
405-
assert(code == OK);
406405
Py_RETURN_NONE;
407406
}
408407
curses_set_error(module, curses_funcname, python_funcname);
@@ -416,7 +415,6 @@ curses_window_check_err(PyCursesWindowObject *win, int code,
416415
const char *python_funcname)
417416
{
418417
if (code != ERR) {
419-
assert(code == OK);
420418
Py_RETURN_NONE;
421419
}
422420
curses_window_set_error(win, curses_funcname, python_funcname);
@@ -1580,7 +1578,7 @@ _curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1,
15801578
win = derwin(self->win,nlines,ncols,begin_y,begin_x);
15811579

15821580
if (win == NULL) {
1583-
curses_window_set_error(self, "derwin", NULL);
1581+
curses_window_set_null_error(self, "derwin", NULL);
15841582
return NULL;
15851583
}
15861584

0 commit comments

Comments
 (0)