Umur Kontacı
Umur Kontacı

Reputation: 35478

In python shell, "b" letter does not work, what the?

Well hello, this is the most interesting bug/conflict I've ever faced.

In python shell, I cannot type lowercase "b". At first I thought something was under the key, but no, in everywhere else it functions very well. Also ctrl+b shift+b even with capslock b works.

Yet more, when I run the shell with sudo (ie. sudo python), my little lowercase "b" works well.

My last move was installing pyexiv2 (using aptitude), I can import it without problems in both with and without sudo. I have removed it but the result didn't change.

What the hell might be wrong?

I am using Ubuntu 10.04 LTS x86 with Python 2.6.5

Further note:
I have installed a vim modifier script which might be the trouble.
Using this:

$ git clone https://github.com/sontek/dotfiles.git
$ cd dotfiles
$ ./install.sh vim

This scripts initiates more git clones, so it might be hard to follow. But it does many changes including the terminal's look.

UPDATE:

1) I even cannot copy/paste "b" character. ctrl+c/v select&middle click both doesnt work.

2) When I open the shell with python -E, the modifiers from the mentioned so called vim script does not appear. And b works well. When I open it with python or python -S the modifications exists and i cannot type b.

3) Good news: I have managed to locate the fault, it is the so called vim script. I have renamed its folder and it worked fine. In couple of hours, I will examine deeply what exactly causes the problem and post it here with detailed results.

Upvotes: 16

Views: 1811

Answers (2)

Gregg Lind
Gregg Lind

Reputation: 21312

The problematic line in your .pythonstartup is something like:

 readline.parse_and_bind("bind ^I rl_complete") # darwin libedit

This .pythonstartup will fix it...

try:
    import readline
except ImportError:
    print "Module readline not available."
else:
    import rlcompleter
    if 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind("tab: complete")

Upvotes: 14

Michael Lorton
Michael Lorton

Reputation: 44436

My money is that the readline on your shell is messed up. Perhaps the 'b' key is bound to auto-complete. Look in your PYTHONSTARTUP variable and see what file it refers to. If that file has something like readline.parse_and_bind ...

I'm betting there's some connection between the fact that it's 'b' (instead of some other letter) and the word 'bind', like there's a variable called bind_to_complete and it's being interpreted literally (and only the first character taken).

Let the mass wild-ass guessing commence!

Upvotes: 8

Related Questions