Skip to content

Commit 894ebd0

Browse files
bpo-31919: Fix building the curses module on OpenIndiana. (#4211)
1 parent 388cd85 commit 894ebd0

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

Lib/test/test_curses.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def test_window_funcs(self):
143143
stdscr.idlok(1)
144144
if hasattr(stdscr, 'immedok'):
145145
stdscr.immedok(1)
146+
stdscr.immedok(0)
146147
stdscr.insch('c')
147148
stdscr.insdelln(1)
148149
stdscr.insnstr('abc', 3)
@@ -176,26 +177,27 @@ def test_window_funcs(self):
176177
stdscr.setscrreg(10,15)
177178
win3 = stdscr.subwin(10,10)
178179
win3 = stdscr.subwin(10,10, 5,5)
179-
if hasattr(stdscr, 'syncok'):
180+
if hasattr(stdscr, 'syncok') and not sys.platform.startswith("sunos"):
180181
stdscr.syncok(1)
181182
stdscr.timeout(5)
182183
stdscr.touchline(5,5)
183184
stdscr.touchline(5,5,0)
184185
stdscr.vline('a', 3)
185186
stdscr.vline('a', 3, curses.A_STANDOUT)
186-
stdscr.chgat(5, 2, 3, curses.A_BLINK)
187-
stdscr.chgat(3, curses.A_BOLD)
188-
stdscr.chgat(5, 8, curses.A_UNDERLINE)
189-
stdscr.chgat(curses.A_BLINK)
187+
if hasattr(stdscr, 'chgat'):
188+
stdscr.chgat(5, 2, 3, curses.A_BLINK)
189+
stdscr.chgat(3, curses.A_BOLD)
190+
stdscr.chgat(5, 8, curses.A_UNDERLINE)
191+
stdscr.chgat(curses.A_BLINK)
190192
stdscr.refresh()
191193

192194
stdscr.vline(1,1, 'a', 3)
193195
stdscr.vline(1,1, 'a', 3, curses.A_STANDOUT)
194196

195-
if hasattr(curses, 'resize'):
196-
stdscr.resize()
197-
if hasattr(curses, 'enclose'):
198-
stdscr.enclose()
197+
if hasattr(stdscr, 'resize'):
198+
stdscr.resize(25, 80)
199+
if hasattr(stdscr, 'enclose'):
200+
stdscr.enclose(10, 10)
199201

200202
self.assertRaises(ValueError, stdscr.getstr, -400)
201203
self.assertRaises(ValueError, stdscr.getstr, 2, 3, -400)
@@ -423,6 +425,8 @@ def test_issue21088(self):
423425

424426
def test_issue13051(self):
425427
stdscr = self.stdscr
428+
if not hasattr(stdscr, 'resize'):
429+
raise unittest.SkipTest('requires curses.window.resize')
426430
box = curses.textpad.Textbox(stdscr, insert_mode=True)
427431
lines, cols = stdscr.getmaxyx()
428432
stdscr.resize(lines-2, cols-2)

Modules/_cursesmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ int py_mvwdelch(WINDOW *w, int y, int x)
941941
#endif
942942

943943
/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
944-
944+
#ifdef HAVE_CURSES_WCHGAT
945945
static PyObject *
946946
PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
947947
{
@@ -994,7 +994,7 @@ PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
994994
}
995995
return PyCursesCheckERR(rtn, "chgat");
996996
}
997-
997+
#endif
998998

999999
static PyObject *
10001000
PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
@@ -1985,7 +1985,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
19851985
{"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
19861986
{"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
19871987
{"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
1988+
#ifdef HAVE_CURSES_WCHGAT
19881989
{"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
1990+
#endif
19891991
{"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
19901992
{"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS},
19911993
{"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS},

configure

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15912,6 +15912,36 @@ $as_echo "no" >&6; }
1591215912
fi
1591315913
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1591415914

15915+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchgat" >&5
15916+
$as_echo_n "checking for wchgat... " >&6; }
15917+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15918+
/* end confdefs.h. */
15919+
#include <curses.h>
15920+
int
15921+
main ()
15922+
{
15923+
15924+
#ifndef wchgat
15925+
void *x=wchgat
15926+
#endif
15927+
15928+
;
15929+
return 0;
15930+
}
15931+
_ACEOF
15932+
if ac_fn_c_try_compile "$LINENO"; then :
15933+
15934+
$as_echo "#define HAVE_CURSES_WCHGAT 1" >>confdefs.h
15935+
15936+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15937+
$as_echo "yes" >&6; }
15938+
else
15939+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15940+
$as_echo "no" >&6; }
15941+
15942+
fi
15943+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15944+
1591515945
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for filter" >&5
1591615946
$as_echo_n "checking for filter... " >&6; }
1591715947
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5033,6 +5033,17 @@ void *x=syncok
50335033
[AC_MSG_RESULT(no)]
50345034
)
50355035

5036+
AC_MSG_CHECKING(for wchgat)
5037+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5038+
#ifndef wchgat
5039+
void *x=wchgat
5040+
#endif
5041+
]])],
5042+
[AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.)
5043+
AC_MSG_RESULT(yes)],
5044+
[AC_MSG_RESULT(no)]
5045+
)
5046+
50365047
AC_MSG_CHECKING(for filter)
50375048
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
50385049
#ifndef filter

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@
179179
/* Define if you have the 'use_env' function. */
180180
#undef HAVE_CURSES_USE_ENV
181181

182+
/* Define if you have the 'wchgat' function. */
183+
#undef HAVE_CURSES_WCHGAT
184+
182185
/* Define to 1 if you have the declaration of `isfinite', and to 0 if you
183186
don't. */
184187
#undef HAVE_DECL_ISFINITE

0 commit comments

Comments
 (0)