Python/editline on OS X: £ sign seems to be bound to ed-prev-word

蓝咒 提交于 2019-12-11 20:14:31

问题


On Mac OS X I can’t enter a pound sterling sign (£) into the Python interactive shell.

* Mac OS X 10.5.5
* Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
* European keyboard (£ is shift-3)

When I type shift-3 in the Python interactive shell, I seem to invoke the previous word function, i.e. the cursor will move to the start of the last “word” (i.e. space-delimited item) typed on the line. When I’m back in the bash shell, typing shift-3 just produces a £, as expected.

This version of Python apparently uses editline for its interactive shell, as opposed to readline. I’m guessing that one of the default editline key bindings binds shift-3 (or whatever editline sees when I type shift-3) to the ed-prev-word command.

I’ve tried a few things in my ~/.editrc file to remove this binding, and they don’t have any effect:

  • bind -r £
  • bind -r \243
  • bind -r \156

And another that causes a bus error:

  • bind £ \243

Any ideas?


回答1:


This may be an editline issue; libedit may not accept UTF-8 characters:

  • http://tracker.firebirdsql.org/browse/CORE-362#action_11593
  • http://marc.info/?t=119056021900002&r=1&w=2


来源:https://stackoverflow.com/questions/217020/python-editline-on-os-x-%c2%a3-sign-seems-to-be-bound-to-ed-prev-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!