Index: setup.py =================================================================== --- setup.py (revision 80180) +++ setup.py (working copy) @@ -550,6 +550,16 @@ # readline do_readline = self.compiler.find_library_file(lib_dirs, 'readline') + readline_curses_library = "" + fp = os.popen("ldd %s" % do_readline) + for ln in fp: + if 'curses' in ln: + readline_curses_library = re.sub( + r'.*lib([a-z]*curses[a-z]*)\.so.*', r'\1', ln + ).rstrip() + break + fp.close() + if platform == 'darwin': os_release = int(os.uname()[2].split('.')[0]) dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') @@ -573,7 +583,11 @@ readline_extra_link_args = () readline_libs = ['readline'] - if self.compiler.find_library_file(lib_dirs, + if readline_curses_library: + # Issue 7384: On FreeBSD, readline is already linked against + # ncurses, so do not link against ncursesw. + pass + elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): readline_libs.append('ncursesw') elif self.compiler.find_library_file(lib_dirs, @@ -1119,7 +1133,15 @@ # Curses support, requiring the System V version of curses, often # provided by the ncurses library. panel_library = 'panel' - if (self.compiler.find_library_file(lib_dirs, 'ncursesw')): + if readline_curses_library: + # If readline is already linked against a specific + # curses version, use the same version here. + curses_libs = [readline_curses_library] + if readline_curses_library == 'ncursesw': + panel_library = 'panelw' + exts.append( Extension('_curses', ['_cursesmodule.c'], + libraries = curses_libs) ) + elif (self.compiler.find_library_file(lib_dirs, 'ncursesw')): curses_libs = ['ncursesw'] # Bug 1464056: If _curses.so links with ncursesw, # _curses_panel.so must link with panelw. Index: Lib/test/test_curses.py =================================================================== --- Lib/test/test_curses.py (revision 80180) +++ Lib/test/test_curses.py (working copy) @@ -21,11 +21,6 @@ curses = import_module('curses') curses.panel = import_module('curses.panel') -# skip all these tests on FreeBSD: test_curses currently hangs the -# FreeBSD buildbots, preventing other tests from running. See issue -# #7384. -if 'freebsd' in sys.platform: - raise unittest.SkipTest('The curses module is broken on FreeBSD. See http://bugs.python.org/issue7384.') # XXX: if newterm was supported we could use it instead of initscr and not exit term = os.environ.get('TERM')