[New-bugs-announce] [issue9907] interactive mode TAB does not insert on OS X built with editline instead of GNU readline

Ned Deily report at bugs.python.org
Mon Sep 20 23:36:47 CEST 2010


New submission from Ned Deily <nad at acm.org>:

When building Python on OS X, there is now support for linking Python with the readline compatibility interface of the OS X supplied BSD editline library rather than using the GNU readline library.  Because of deficiencies in the version in earlier OS X releases, this support is only enabled for builds with a deployment target of 10.5 or higher.  With the python 2.7 release, for the first time a python.org installer for OS X is available that uses this capability: the 10.5 and higher 32-bit/64-bit version. The 10.3 and higher 32-bit-only installer uses GNU readline as do previous installers.  There is a behavior regression in the editline-linked versions: when started in interactive mode, the TAB key does not insert, rather it inserts a "./" file spec in the command buffer and a second TAB causes a completion search of files in the current directory.

With readline and typing <TAB> <CR>:

  $ unset PYTHONSTARTUP 
  $ python2.7
  Python 2.7 (r27:82508, Jul  3 2010, 20:17:05) 
  [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>>     
  ... 
  $ 

With editline and <TAB> <CR>:

  $ unset PYTHONSTARTUP 
  $ python2.7
  Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
  [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> ./
    File "<stdin>", line 1
      ./
      ^
  SyntaxError: invalid syntax
  >>> ^D

Two workarounds for python2.7 until the problem is addressed in a future installer:

   (1) either install the 10.3 and up python 2.7

or (2) add or edit a python startup file for python2.7:

       $ cat > $HOME/.pystartup
       import readline
       if 'libedit' in readline.__doc__:
           readline.parse_and_bind("bind ^I ed-insert")
       ^D
       $ export PYTHONSTARTUP=$HOME/.pystartup


Since whitespace is significant in Python, Modules/readline.c initialization attempts to override TAB behavior by forcing TAB to "insert" by default (unless overridden by later readline module calls).  Somehow that is failing when going through editline's readline compatibility layer.

----------
assignee: ronaldoussoren
components: Macintosh
messages: 116981
nosy: ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: interactive mode TAB does not insert on OS X built with editline instead of GNU readline
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9907>
_______________________________________


More information about the New-bugs-announce mailing list