Edgewall Software
Modify

Opened 10 years ago

Closed 10 years ago

Last modified 2 years ago

#8711 closed defect (fixed)

readline 6 breaks tab completion in trac-admin

Reported by: Remy Blank Owned by: Remy Blank
Priority: low Milestone: 0.12
Component: admin/console Version: 0.12dev
Severity: normal Keywords: readline
Cc: Branch:
Release Notes:
API Changes:

Description

Since I upgraded to readline 6, tab completion in trac-admin is broken (or at least, it has become weird):

  • When the current word completes to a single suggestion, two spaces are appended to the completed word instead of one. This is due to trac-admin appending a space in that case, and readline appending a second one. Previously, readline did not append a space.
  • If the code appending a space is removed from trac-admin, completion of file and directory paths is still broken, as a space is appended e.g. after a /, so for example "/tm" is completed to "/tmp/ " (with a trailing space), which completely defeats the purpose of completion.

I am not absolutely sure that this was introduced with readline 6, as I wasn't able to downgrade to version 5.2, but the upgrade was done shortly before I noticed the issue.

Attachments (2)

8711-readline-trailing-space-r8634.patch (1.3 KB ) - added by Remy Blank 10 years ago.
Avoid trailing space on tab completion.
8711-readline-trailing-space-r8634.2.patch (1.7 KB ) - added by Remy Blank 10 years ago.
Hack over hack to find the exact libreadline linked to the readline module.

Download all attachments as: .zip

Change History (13)

comment:1 by Christian Boos, 10 years ago

See PythonBug:5833. But as the proposed fix is at the C Python level, we would still need to find a workaround of our own…

comment:2 by Remy Blank, 10 years ago

Yes, I have finally found that bug as well. I have tried to find a workaround, but as mentioned above, even removing the extra space doesn't fix completion for paths, and an extra space for commands doesn't hurt either.

Maybe I could try to fix rl_completion_append_character and rl_completion_suppress_append using ctypes? It wouldn't work on all installations, but probably on most. I'll try that.

by Remy Blank, 10 years ago

Avoid trailing space on tab completion.

comment:3 by Remy Blank, 10 years ago

The patch above (against trunk) fixes the issue for me on Linux. It imports rl_completion_suppress_append from the readline library using ctypes and sets it to 0 in the completion function.

For some reason, it doesn't seem to work on OS X. Investigating…

comment:4 by Remy Blank, 10 years ago

It seems that find_library() just finds the first library in the dynamic linker path, not necessarily the one that was linked against the readline module. And on my OS X, that's not the right one.

Any idea how I could find the path of the readline library linked with the readline module?

(Then again, this solution seems to me like a huge hack. Any better ideas?)

by Remy Blank, 10 years ago

Hack over hack to find the exact libreadline linked to the readline module.

comment:5 by Remy Blank, 10 years ago

The second hack^Wpatch above gets the name of the readline library from the readline module directly, and works on both Linux and OS X. But to be honest, I'm almost ashamed of it.

comment:6 by Remy Blank, 10 years ago

Owner: set to Remy Blank

in reply to:  5 ; comment:7 by Christian Boos, 10 years ago

Replying to rblank:

The second hack^Wpatch above gets the name of the readline library from the readline module directly, and works on both Linux and OS X. But to be honest, I'm almost ashamed of it.

Well, don't :-) If this is the only way to make trac-admin conveniently usable for your system (and it doesn't break things for other versions of readline), go for it.

Users won't necessarily look under the hood of trac-admin but they'll certainly notice if its command-line completion is broken. The only other option would be to disable completion. For those who do look under the hood, a comment explaining why all this extra complexity is needed would be welcomed.

I verified that the patches don't break anything when using an older version of readline (libreadline.so.4) on Linux.

On Windows, I just noticed that the completion seems to be broken: it works for the very first completion (and that triggers initialization of the environment), then it stops working. But that's not due to your patches.

in reply to:  7 ; comment:8 by Remy Blank, 10 years ago

Milestone: not applicable0.12

Replying to cboos:

Well, don't :-) If this is the only way to make trac-admin conveniently usable for your system (and it doesn't break things for other versions of readline), go for it.

Well, what I find especially ugly is opening the (binary) readline module and hoping to find the name or path of libreadline in there using a regex…

Also, this hack will only be needed until the readline module gets fixed in Python (which will probably be the case for 2.6 only, so it will still be useful for 2.5 and 2.4).

I'll commit to trunk, and in any case, if the hack doesn't work, at least it doesn't get worse than the current state.

On Windows, I just noticed that the completion seems to be broken: it works for the very first completion (and that triggers initialization of the environment), then it stops working. But that's not due to your patches.

I didn't know the readline was available on Windows (says Unix in the Python docs). Are you using cygwin?

in reply to:  8 comment:9 by Christian Boos, 10 years ago

Replying to rblank:

I didn't know the readline was available on Windows (says Unix in the Python docs). Are you using cygwin?

No, pyreadline.

comment:10 by Remy Blank, 10 years ago

Resolution: fixed
Status: newclosed

Patch applied in [8641].

comment:11 by Ryan J Ollos, 2 years ago

#12884 will investigate reverting r8641 on trunk now that Python 2.7 is the only supported Python. It appears the issue is fixed in Python 2.6.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.