bpython / bpython

bpython - A fancy curses interface to the Python interactive interpreter
https://bpython-interpreter.org/
Other
2.63k stars 238 forks source link

KeyboardInterrupt not sent on cli #177

Open ikanobori opened 10 years ago

ikanobori commented 10 years ago

My cli at least doesn't do the whole keyboard-interrupt-to-clear-line thing that I've gotten so used to having. I think it's because getkey within curses catches and processes it and it actually has to be raised within the p_key function. This is all speculation since I don't know how either bpython nor curses really works. I attached a diff that fixes the problem for me but not entirely sure if this would break anything else so should be reviewed by someone that actually knows how things work :P.

In case this is system specific issue, I'm running bpython against python 2.6.1 on Mac OS X 10.6.6


ikanobori commented 10 years ago

Setting this resolved, recreate if it is broken in the new frontend.


Original Comment By: Simon de Vlieger

ikanobori commented 10 years ago

For folks to whom this is important, ctrl-c works more like it does in vanilla python in bpython-curtsies, another bpython frontend now in trunk.


Original Comment By:

ikanobori commented 10 years ago

I'd just like to +1 this issue.

I'm running bpython on Ubuntu 12.10, and the single most show-stopping bpython behavior, preventing me from using bpython as my 'default' REPL, is that when I'm at the command line, typing code, I can't press CTRL+c to break out of the currently line.

In the normal python REPL, it's really useful to do this as I find myself frequently experimenting with new things, trying different combinations, etc., and having to manually backspace across the screen takes way longer and is a quite a bit more tedious than a quick CTRL+c tap.


Original Comment By: Randall Degges

ikanobori commented 10 years ago

Issue #192 was marked as a duplicate of this issue.


Original Comment By: Sebastian Ramacher

ikanobori commented 10 years ago

I agree that our handling of ctrl-c is somewhat different from vanilla Python (or, IOW: "broken"). Unfortunately, your patch seems to introduce some other issues. I'll try again later this day, please feel free to bump this issue if I forget about it.


Original Comment By: Andreas Stührk

eliasdorneles commented 7 years ago

I've just test the ^C behavior using the latest code from master, and it works as expected in Python 2.7 but doesn't in Python 3.5.

See:

$ bpython
bpython version 0.17.dev55 on top of Python 2.7.12 /home/elias/.virtualenvs/bpython/bin/python
>>> d = {}
>>> d.get(
... # will hit Ctrl-C now
... 
KeyboardInterrupt
>>> 

In Python 3.5, I only see the result of KeyboardInterrupt after hitting Enter:

$ bpython
bpython version 0.17.dev55 on top of Python 3.5.2 /home/elias/.virtualenvs/bpython3/bin/python3
>>> d = {}
>>> d.get(
... # will hit Ctrl-C now
... 
... 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> # the above was result of hitting Ctrl-C three times and then hitting ENTER
snauhaus commented 7 years ago

I have the exact same issue as @eliasdorneles running bpython 0.16 in python 3.6.0 on OS X 10.12.5:

This will not interrupt any code execution, though. Accidentally printing a very large list, or so, will not get interrupted by Ctrl-C..

Ir1d commented 5 years ago

Hi, any update on this? it will be really nice if Ctrl-C acts as a KeyboardInterrupt

kgskgs commented 5 years ago

+1 it should interrupt code execution

yankyhoffman commented 4 years ago

I just started using bpython and I love it, however this bug is really bugging me OS: Ubuntu 19.10 Terminal: gnome-terminal BPython Version:

$ bpython3
bpython version 0.18 on top of Python 3.7.5 /usr/bin/python3