spurious trailing space after tab completion

Bug #470824 reported by Peter Bienstman
126
This bug affects 25 people
Affects Status Importance Assigned to Milestone
IPython
Invalid
Undecided
Unassigned
Python
Fix Released
Unknown
Gentoo Linux
Fix Released
Medium
bash-completion (Ubuntu)
Fix Released
Undecided
Unassigned
Declined for Karmic by Martin Pitt
Nominated for Lucid by Robert Schroll
python2.6 (Ubuntu)
Fix Released
Medium
Unassigned
Declined for Karmic by Martin Pitt
Nominated for Lucid by Robert Schroll

Bug Description

When linked against readline6, Python's readline module inserts a space after tab completions. This differs from previous versions and in most cases is unwanted.

TEST CASE:
$ python
>>> import rlcompleter
>>> import readline
>>> readline.parse_and_bind('tab: complete')
>>> read<TAB>

Should expand to "readline" with no trailing space.

Original description:
Using IPython 0.10, when I use tab completion after cd, IPython inserts an extra space at the end of the trailing /. This makes it hard to use tab completion again to go into a subdirectory.
Strangely enough, after ls, no trailing space gets inserted.

Revision history for this message
Ville M. Vainio (villemvainio) wrote : Re: [Bug 470824] [NEW] spurious trailing space after tab completion in cd

On Mon, Nov 2, 2009 at 4:11 PM, Peter Bienstman
<email address hidden> wrote:

> Public bug reported:
>
> Using IPython 0.10, when I use tab completion after cd, IPython inserts an extra space at the end of the trailing /. This makes it hard to use tab completion again to go into a subdirectory.
> Strangely enough, after ls, no trailing space gets inserted.

Yeah, the problem is that karmic broke readline in this respect again.

Workaround is doing

greedy_cd_completer = True

in ipy_completers.py

--
Ville M. Vainio
http://tinyurl.com/vainio

Revision history for this message
Lakshman Prasad (scorpion032) wrote : Re: spurious trailing space after tab completion in cd

The problem is not limited to cd alone,

Any "complete" auto-complete adds an extra trailing space. This may be a desired feature on the general shell, but not on a python shell where typically, an operation needs to be performed on it, followed by a "."

While I haven't gone through the code in detail, the greedy_cd_completer seems to affect only the cd auto completion.

There trailing space problems needs to address, I believe the following problems:

In the under, **I represent space, by +, for conveying**

1) from<tab> : No space, it is expected.

In [1]: fro
from frozenset

In [1]: from

2) Module name auto complete adds a space, while not expected

In [1]: from IPython+

3) Extra trailing space after import

In [1]: from IPython.Shell import++

WRT the Original report that wonders why the space is not added after ls, clearly it is because, %ls is an alias to %lsmagic and ls prompts both these as the options.

If my observation is right, I plan to write a test for this; and try to fix it.

Revision history for this message
Jan Hülsbergen (jan-afoo) wrote :

http://bugs.python.org/issue5833

someone more familiar with this bugtracker should move the bug to python and add a +patch tag.

Daniel Hahler (blueyed)
Changed in ipython:
status: New → Invalid
Changed in python-defaults (Ubuntu):
status: New → Triaged
affects: python-defaults (Ubuntu) → python2.6 (Ubuntu)
Changed in python2.6 (Ubuntu):
importance: Undecided → Medium
Changed in python:
status: Unknown → New
Revision history for this message
Robert Schroll (rschroll) wrote :

This seems to have been fixed with revisions 75531 and 75725 in the Python trunk, but these didn't make it into 2.6.4. Might these be imported to Ubuntu's version?

Alternatively: This problem seems to have been caused by changes between readline5 and readline6. If I link /lib/readline.so.6 to point to libreadline.so.5.2 instead of libreadline.so.6.0, tab completion within python works as expected. Perhaps python could be linked against readline5 for now.

Changed in gentoo:
status: Unknown → Confirmed
summary: - spurious trailing space after tab completion in cd
+ spurious trailing space after tab completion
Revision history for this message
Robert Schroll (rschroll) wrote :

A demonstration of this bug in the standard python interpreter:

>>> import rlcompleter
>>> import readline
>>> readline.parse_and_bind('tab: complete')
>>> read<TAB>

In previous versions (with readline5), this expands to "readline". In Karmic (with readline6), this expands to "readline<SPACE>". Although this extra space doesn't break any python functionality, it does disrupt further tab completions. "readline<SPACE>.parse<TAB>" will not be completed, while "readline.parse<TAB>" will.

description: updated
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Closing as invalid, since this isn't really our bug, it's Python's.

Revision history for this message
Robert Schroll (rschroll) wrote :

This issue has been fixed in Python's 2.6 maintenance branch with revision 75747. (Here's the patch itself: http://svn.python.org/view/python/branches/release26-maint/Modules/readline.c?r1=75747&r2=75746&pathrev=75747&view=patch) What do I need to do to get this into Ubuntu's versions?

Revision history for this message
Fernando Perez (fdo.perez) wrote : Re: [Bug 470824] Re: spurious trailing space after tab completion

On Sun, Jan 10, 2010 at 1:55 PM, Robert Schroll <email address hidden> wrote:
> This issue has been fixed in Python's 2.6 maintenance branch with
> revision 75747.  (Here's the patch itself:
> http://svn.python.org/view/python/branches/release26-maint/Modules/readline.c?r1=75747&r2=75746&pathrev=75747&view=patch)
> What do I need to do to get this into Ubuntu's versions?

I don't know specifically what the ubuntu policy is regarding
backports of fixes like this, but I'd start here:

http://packages.ubuntu.com/karmic/python/python

This is the actual package page, you might have luck either reporting
this to their bug tracker, or contacting the team members directly.

It would really be great to have this done upstream; all my machines
use ubuntu and this stupid backspacing is driving me crazy...

Cheers,

f

Revision history for this message
Robert Schroll (rschroll) wrote :

Sorry - I did not intend to nominate for Lucid. It appears that Lucid recently pulled in changes from Python's 2.6 maintenance branch, so I assume this is fixed there (though I haven't checked). I can't figure out how to undo the nomination, though.

Nonetheless, what are the chances of getting this fix into Karmic?

Revision history for this message
Joe_Bishop (denis-cheremisov-gmail) wrote :

Yes, the problem was fixed in Lucid.

Revision history for this message
Ludwig Schwardt (ludwig-schwardt) wrote :

One solution to this problem is to install the readline package from PyPI (i.e. easy_install readline). The latest version (2.6.4) includes the fix from the Python maintenance branch mentioned above (r75747). It also works fine on Snow Leopard and Ubuntu.

Revision history for this message
Fernando Perez (fdo.perez) wrote :

On Sun, Jan 31, 2010 at 2:47 PM, Ludwig Schwardt
<email address hidden> wrote:
> One solution to this problem is to install the readline package from
> PyPI (i.e. easy_install readline). The latest version (2.6.4) includes
> the fix from the Python maintenance branch mentioned above (r75747). It
> also works fine on Snow Leopard and Ubuntu.

That's great to know, excellent. With a local install, one can keep
the fix for now, and then remove it once upstream includes it in a new
system python release.

Thanks!

f

Changed in python2.6 (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Adam Collard (adam-collard) wrote :

This was fixed in 2.6.4-4

tags: added: regression-release
Revision history for this message
Robert Schroll (rschroll) wrote :

> This was fixed in 2.6.4-4

Does this mean that I should not expect this fix to make it into Karmic?

description: updated
Revision history for this message
Adam Collard (adam-collard) wrote :

SRU: minimal diff available on attached branch (please indicate if an attached patch is preferable).

Nominating for SRU. Fulfils "(1) have an obviously safe patch and (2) affect an application rather than critical infrastructure packages". The application here being the Python command line - isn't believed to have an impact on Python interpreter in the general case.

Fix is from upstream and is already available in Lucid, the bug being a regression introduced in Karmic.

Revision history for this message
Adam Collard (adam-collard) wrote :
Revision history for this message
Adam Collard (adam-collard) wrote :

Note that the same changes are available in my PPA https://edge.launchpad.net/~adam-collard/+archive/ppa and have been tested by at least two people other than myself

Revision history for this message
Robert Schroll (rschroll) wrote :

I can confirm that Adam Collard's PPA version solves this issue. I have not seen any side effects.

Adam, thanks for putting this PPA together. If there's anything I can do to help, please let me know.

Revision history for this message
Martin Pitt (pitti) wrote :

This does not match the Stable Release Updates criteria IMHO, and is not worth the risk and effort of an SRU.

Changed in gentoo:
status: Confirmed → Fix Released
Changed in gentoo:
importance: Unknown → Medium
Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :

Workaround for bash-completion: disable it (complete -r), and just use the native completion (i.e. complete-everything). This is more usable than a spurious space after every tab in bash.

Changed in python:
status: New → Fix Released
Changed in bash-completion (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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