Skip to content

Commit 2be9a31

Browse files
miss-islingtonserhiy-storchaka
authored andcommitted
bpo-31919: Fix building the curses module on OpenIndiana. (GH-4211) (#4215)
(cherry picked from commit 894ebd0)
1 parent 89b84b0 commit 2be9a31

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
@@ -943,7 +943,7 @@ int py_mvwdelch(WINDOW *w, int y, int x)
943943
#endif
944944

945945
/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
946-
946+
#ifdef HAVE_CURSES_WCHGAT
947947
static PyObject *
948948
PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
949949
{
@@ -996,7 +996,7 @@ PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
996996
}
997997
return PyCursesCheckERR(rtn, "chgat");
998998
}
999-
999+
#endif
10001000

10011001
static PyObject *
10021002
PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
@@ -2001,7 +2001,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
20012001
{"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
20022002
{"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
20032003
{"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
2004+
#ifdef HAVE_CURSES_WCHGAT
20042005
{"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
2006+
#endif
20052007
{"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
20062008
{"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS},
20072009
{"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS},

configure

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

16113+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchgat" >&5
16114+
$as_echo_n "checking for wchgat... " >&6; }
16115+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16116+
/* end confdefs.h. */
16117+
#include <curses.h>
16118+
int
16119+
main ()
16120+
{
16121+
16122+
#ifndef wchgat
16123+
void *x=wchgat
16124+
#endif
16125+
16126+
;
16127+
return 0;
16128+
}
16129+
_ACEOF
16130+
if ac_fn_c_try_compile "$LINENO"; then :
16131+
16132+
$as_echo "#define HAVE_CURSES_WCHGAT 1" >>confdefs.h
16133+
16134+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
16135+
$as_echo "yes" >&6; }
16136+
else
16137+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
16138+
$as_echo "no" >&6; }
16139+
16140+
fi
16141+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16142+
1611316143
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for filter" >&5
1611416144
$as_echo_n "checking for filter... " >&6; }
1611516145
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,6 +5071,17 @@ void *x=syncok
50715071
[AC_MSG_RESULT(no)]
50725072
)
50735073

5074+
AC_MSG_CHECKING(for wchgat)
5075+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5076+
#ifndef wchgat
5077+
void *x=wchgat
5078+
#endif
5079+
]])],
5080+
[AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.)
5081+
AC_MSG_RESULT(yes)],
5082+
[AC_MSG_RESULT(no)]
5083+
)
5084+
50745085
AC_MSG_CHECKING(for filter)
50755086
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
50765087
#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)