Catch exception in rlineimpl

Bug #416162 reported by Robert Kern
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
High
Fernando Perez

Bug Description

On OS X, the check for libedit/libreadline linkage fails in some circumstances, notably running under PyQt4. The attached patch catches this error and assumes a proper libreadline.

Revision history for this message
Robert Kern (robert-kern) wrote :
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Mmh, I hadn't seen this. I just closed the same bug with a slightly different patch:

https://bugs.launchpad.net/ipython/+bug/411599

What I used was instead:

=== modified file 'IPython/utils/rlineimpl.py'
--- IPython/utils/rlineimpl.py 2010-01-30 00:24:13 +0000
+++ IPython/utils/rlineimpl.py 2010-04-25 03:34:23 +0000
@@ -35,7 +35,19 @@
 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")

Do you think it makes sense to keep retrying at all, or should we just switch to your approach which does a single try and then skips ahead? Just let me know (I'm not on OSX) and I'll apply your version instead if you think that's the right approach.

Thanks!

Changed in ipython:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Fernando Perez (fdo.perez)
milestone: none → 0.10.1
milestone: 0.10.1 → 0.11
Revision history for this message
Darrell Schiebel (darrell-schiebel) wrote :

You should at least try more than once. When using gdb it often happens that you get an "interrupted system call" error. I'm not sure what is going on within within gdb to cause this, but when it happens it's very annoying. Skipping ahead would result in start up errors. I would think trying 10 time is more than enough.

Darrell

Revision history for this message
Fernando Perez (fdo.perez) wrote : Re: [Bug 416162] Re: Catch exception in rlineimpl

On Sun, Apr 25, 2010 at 7:08 AM, Darrell Schiebel <email address hidden> wrote:
> You should at least try more than once. When using gdb it often happens
> that you get an "interrupted system call" error. I'm not sure what is
> going on within within gdb to cause this, but when it happens it's very
> annoying. Skipping ahead would result in start up errors. I would think
> trying 10 time is more than enough.

Ah, OK, this is very useful info. In that case, it seems the patch as
committed is solid. Unless either of you tells me otherwise, I'll
leave it as-is.

Thanks!

f

Changed in ipython:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.