[IPython-dev] pyreadline vi mode fix

Michael Graz mg.graz at googlemail.com
Thu Jul 19 12:21:33 EDT 2007


Greetings all, LTNS.  When I enable vi mode (set_mode("vi") in
~/pyreadlineconfig.ini) there is an exception and then nothing works.
However there is an easy fix in rlmain.py function parse_and_bind.

before:

    except AttributeError:
        log('unknown func key="%s" func="%s"' % (key, func_name))
        print 'unknown function to bind: "%s"' % func_name
    self.mode._bind_key (key, func)

after:

    except AttributeError:
        log('unknown func key="%s" func="%s"' % (key, func_name))
        print 'unknown function to bind: "%s"' % func_name
        return
    self.mode._bind_key(key, func)

It is simply the addition of a return call in the exception handling block.
If there is no return then "func" is an undefined variable resulting in an
exception in the statement: self.mode._bind_key(key, func)

    UnboundLocalError: local variable 'func' referenced before assignment

Would someone be able to checkin this fix?  Many thanks,
-Mike

(2nd attempt at mailing)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070719/0a9177a3/attachment.html>


More information about the IPython-dev mailing list