#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: | |||
Internal 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)
Change History (13)
comment:1 by , 15 years ago
comment:2 by , 15 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 , 15 years ago
Attachment: | 8711-readline-trailing-space-r8634.patch added |
---|
Avoid trailing space on tab completion.
comment:3 by , 15 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 , 15 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 , 15 years ago
Attachment: | 8711-readline-trailing-space-r8634.2.patch added |
---|
Hack over hack to find the exact libreadline
linked to the readline
module.
follow-up: 7 comment:5 by , 15 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 , 15 years ago
Owner: | set to |
---|
follow-up: 8 comment:7 by , 15 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.
follow-up: 9 comment:8 by , 15 years ago
Milestone: | not applicable → 0.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?
comment:9 by , 15 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.
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…