diff setup.py @ 63053:e05b646d6b98 2.7

Issue #7384: On Gentoo, libreadline.so is a "fake library", so ldd fails. In that case, do not attempt to parse stderr output.
author Stefan Krah <stefan@bytereef.org>
date Sat, 17 Jul 2010 12:21:08 +0000
parents a3dd39e36c9d
children e13ea83e2edb
line wrap: on
line diff
--- a/setup.py	Sat Jul 17 01:35:16 2010 +0000
+++ b/setup.py	Sat Jul 17 12:21:08 2010 +0000
@@ -594,16 +594,18 @@
         # Determine if readline is already linked against curses or tinfo.
         if do_readline and find_executable('ldd'):
             fp = os.popen("ldd %s" % do_readline)
-            for ln in fp:
-                if 'curses' in ln:
-                    readline_termcap_library = re.sub(
-                        r'.*lib(n?cursesw?)\.so.*', r'\1', ln
-                    ).rstrip()
-                    break
-                if 'tinfo' in ln: # termcap interface split out from ncurses
-                    readline_termcap_library = 'tinfo'
-                    break
-            fp.close()
+            ldd_output = fp.readlines()
+            ret = fp.close()
+            if ret is None or ret >> 8 == 0:
+                for ln in ldd_output:
+                    if 'curses' in ln:
+                        readline_termcap_library = re.sub(
+                            r'.*lib(n?cursesw?)\.so.*', r'\1', ln
+                        ).rstrip()
+                        break
+                    if 'tinfo' in ln: # termcap interface split out from ncurses
+                        readline_termcap_library = 'tinfo'
+                        break
         # Issue 7384: If readline is already linked against curses,
         # use the same library for the readline and curses modules.
         if 'curses' in readline_termcap_library: