From ffa96dbc431628218dec604d59bb80511af40751 2010-04-25 03:35:08 From: Fernando Perez Date: 2010-04-25 03:35:08 Subject: [PATCH] Fix readline detection bug in OSX. Close https://bugs.launchpad.net/ipython/+bug/411599 Thanks to a patch by Boyd Waters. --- diff --git a/IPython/utils/rlineimpl.py b/IPython/utils/rlineimpl.py index 8f90d40..07a359d 100644 --- a/IPython/utils/rlineimpl.py +++ b/IPython/utils/rlineimpl.py @@ -35,7 +35,19 @@ if sys.platform == 'win32' and have_readline: uses_libedit = False if sys.platform == 'darwin' and have_readline: import commands - (status, result) = commands.getstatusoutput( "otool -L %s | grep libedit" % _rl.__file__ ) + # Boyd's patch had a 'while True' here, I'm always a little worried about + # infinite loops with such code, so for now I'm taking a more conservative + # approach. See https://bugs.launchpad.net/ipython/+bug/411599. + for i in range(10): + try: + (status, result) = commands.getstatusoutput( "otool -L %s | grep libedit" % _rl.__file__ ) + break + except IOError, (errno, strerror): + if errno == 4: + continue + else + break + if status == 0 and len(result) > 0: # we are bound to libedit - new in Leopard _rl.parse_and_bind("bind ^I rl_complete")