8000 bpo-31891: Fix building the curses module on NetBSD. by serhiy-storchaka · Pull Request #4165 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-31891: Fix building the curses module on NetBSD. #4165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions Include/py_curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
** against multiple definition of wchar_t.
*/
#ifdef _BSD_WCHAR_T_DEFINED_
#ifdef _BSD_WCHAR_T_DEFINED_
#define _WCHAR_T
#endif

Expand All @@ -22,7 +22,7 @@
** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
** against multiple definition of wchar_t and wint_t.
*/
#ifdef _XOPEN_SOURCE_EXTENDED
#ifdef _XOPEN_SOURCE_EXTENDED
#ifndef __FreeBSD_version
#include <osreldate.h>
#endif
Expand All @@ -48,10 +48,6 @@
#include <ncurses.h>
#else
#include <curses.h>
#ifdef HAVE_TERM_H
/* for tigetstr, which is not declared in SysV curses */
#include <term.h>
#endif
#endif

#ifdef HAVE_NCURSES_H
Expand All @@ -74,12 +70,12 @@ extern "C" {
/* Type declarations */

typedef struct {
PyObject_HEAD
WINDOW *win;
char *encoding;
PyObject_HEAD
WINDOW *win;
char *encoding;
} PyCursesWindowObject;

#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)
#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)

#define PyCurses_CAPSULE_NAME "_curses._C_API"

Expand Down
32 changes: 24 additions & 8 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@

# If either of these don't exist, skip the tests.
curses = import_module('curses')
import_module('curses.panel')
import_module('curses.ascii')
import_module('curses.textpad')
try:
import curses.panel
except ImportError:
pass

def requires_curses_func(name):
return unittest.skipUnless(hasattr(curses, name),
Expand Down Expand Up @@ -135,7 +138,8 @@ def test_window_funcs(self):

stdscr.idcok(1)
stdscr.idlok(1)
stdscr.immedok(1)
if hasattr(stdscr, 'immedok'):
stdscr.immedok(1)
stdscr.insch('c')
stdscr.insdelln(1)
stdscr.insnstr('abc', 3)
Expand Down Expand Up @@ -169,7 +173,8 @@ def test_window_funcs(self):
stdscr.setscrreg(10,15)
win3 = stdscr.subwin(10,10)
win3 = stdscr.subwin(10,10, 5,5)
stdscr.syncok(1)
if hasattr(stdscr, 'syncok'):
stdscr.syncok(1)
stdscr.timeout(5)
stdscr.touchline(5,5)
stdscr.touchline(5,5,0)
Expand Down Expand Up @@ -208,15 +213,19 @@ def test_module_funcs(self):
"Test module-level functions"
for func in [curses.baudrate, curses.beep, curses.can_change_color,
curses.cbreak, curses.def_prog_mode, curses.doupdate,
curses.filter, curses.flash, curses.flushinp,
curses.flash, curses.flushinp,
curses.has_colors, curses.has_ic, curses.has_il,
curses.isendwin, curses.killchar, curses.longname,
curses.nocbreak, curses.noecho, curses.nonl,
curses.noqiflush, curses.noraw,
curses.reset_prog_mode, curses.termattrs,
curses.termname, curses.erasechar, curses.getsyx]:
curses.termname, curses.erasechar]:
with self.subTest(func=func.__qualname__):
func()
if hasattr(curses, 'filter'):
curses.filter()
if hasattr(curses, 'getsyx'):
curses.getsyx()

# Functions that actually need arguments
if curses.tigetstr("cnorm"):
Expand All @@ -240,15 +249,18 @@ def test_module_funcs(self):
curses.putp(b'abc')
curses.qiflush()
curses.raw() ; curses.raw(1)
curses.setsyx(5,5)
if hasattr(curses, 'setsyx'):
curses.setsyx(5,5)
curses.tigetflag('hc')
curses.tigetnum('co')
curses.tigetstr('cr')
curses.tparm(b'cr')
curses.typeahead(sys.__stdin__.fileno())
if hasattr(curses, 'typeahead'):
curses.typeahead(sys.__stdin__.fileno())
curses.unctrl('a')
curses.ungetch('a')
curses.use_env(1)
if hasattr(curses, 'use_env'):
curses.use_env(1)

# Functions only available on a few platforms
def test_colors_funcs(self):
Expand Down Expand Up @@ -282,6 +294,7 @@ def test_getmouse(self):
curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
m = curses.getmouse()

@requires_curses_func('panel')
def test_userptr_without_set(self):
w = curses.newwin(10, 10)
p = curses.panel.new_panel(w)
Expand All @@ -290,6 +303,7 @@ def test_userptr_without_set(self):
msg='userptr should fail since not set'):
p.userptr()

@requires_curses_func('panel')
def test_userptr_memory_leak(self):
w = curses.newwin(10, 10)
p = curses.panel.new_panel(w)
Expand All @@ -302,6 +316,7 @@ def test_userptr_memory_leak(self):
self.assertEqual(sys.getrefcount(obj), nrefs,
"set_userptr leaked references")

@requires_curses_func('panel')
def test_userptr_segfault(self):
panel = curses.panel.new_panel(self.stdscr)
class A:
Expand All @@ -310,6 +325,7 @@ def __del__(self):
panel.set_userptr(A())
panel.set_userptr(None)

@requires_curses_func('panel')
def test_new_curses_panel(self):
panel = curses.panel.new_panel(self.stdscr)
self.assertRaises(TypeError, type(panel))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed building the curses module on NetBSD.
Loading
0