From b5a05e79c9f39a5e54598bc17316e6085bbbe969 2010-04-25 03:36:57 From: Fernando Perez Date: 2010-04-25 03:36:57 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/rlineimpl.py b/IPython/rlineimpl.py index aa0ba63..b5afb3c 100644 --- a/IPython/rlineimpl.py +++ b/IPython/rlineimpl.py @@ -33,7 +33,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")