Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e2e990

Browse files
committed
Fix build error in _curses module when not using libncursesw.
Code extracted from Victor Stinner's patch for issue #12567.
1 parent 4fbff6c commit 9e2e990

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Modules/_cursesmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
906906
}
907907
}
908908

909+
#ifdef HAVE_NCURSESW
909910
static PyObject *
910911
PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
911912
{
@@ -937,6 +938,7 @@ PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
937938
}
938939
return PyLong_FromLong(rtn);
939940
}
941+
#endif
940942

941943
static PyObject *
942944
PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args)
@@ -1636,7 +1638,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
16361638
{"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
16371639
{"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
16381640
{"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
1641+
#ifdef HAVE_NCURSESW
16391642
{"get_wch", (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
1643+
#endif
16401644
{"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
16411645
{"getparyx", (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},
16421646
{"getstr", (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS},

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,10 @@ class db_found(Exception): pass
11611161
else:
11621162
missing.extend(['nis', 'resource', 'termios'])
11631163

1164+
curses_defines = []
1165+
if curses_library == 'ncursesw':
1166+
curses_defines.append(('HAVE_NCURSESW', '1'))
1167+
11641168
# Curses support, requiring the System V version of curses, often
11651169
# provided by the ncurses library.
11661170
panel_library = 'panel'
@@ -1171,6 +1175,7 @@ class db_found(Exception): pass
11711175
panel_library = 'panelw'
11721176
curses_libs = [curses_library]
11731177
exts.append( Extension('_curses', ['_cursesmodule.c'],
1178+
define_macros=curses_defines,
11741179
libraries = curses_libs) )
11751180
elif curses_library == 'curses' and platform != 'darwin':
11761181
# OSX has an old Berkeley curses, not good enough for
@@ -1183,6 +1188,7 @@ class db_found(Exception): pass
11831188
curses_libs = ['curses']
11841189

11851190
exts.append( Extension('_curses', ['_cursesmodule.c'],
1191+
define_macros=curses_defines,
11861192
libraries = curses_libs) )
11871193
else:
11881194
missing.append('_curses')

0 commit comments

Comments
 (0)