This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Deferred KeyboardInterrupt in interactive mode
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: 22923 Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, martin.panter, serhiy.storchaka
Priority: normal Keywords:

Created on 2012-10-06 19:32 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (8)
msg172238 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-06 19:32
Here are some strange behavior I see (on Linux).

Run Python in interactive mode. Press <Tab><Tab>. Message "Display all XXX possibilities? (y or n)" showed. Press <Ctrl-C>, then <n>. Prompt showed. Enter any text (or none) and press <Enter>. KeyboardInterrupt exception raised.

In Python 2.7:
Traceback (most recent call last):
  File "/usr/lib/python2.7/encodings/utf_8.py", line 15, in decode
    def decode(input, errors='strict'):
KeyboardInterrupt

In Python 3.x:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyboardInterrupt

In Python 2.6 exception not raised.

It does not lead to any detrimental consequences (entered text saved in history and can be restored), but it looks very strange. Possibly for this must be some bug.
msg173037 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-10-16 12:44
My Python interpreter does not have auto-completion.  Do you import something special at startup?
msg173039 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-16 13:06
Nothing. I think it depends if Python was build with readline support.
msg174472 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-01 20:32
Amaury, run the followed commands:

  import readline, rlcompleter
  readline.parse_and_bind('tab: complete')

Hint: you can add this to your .pythonrc.py.
msg252908 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-10-13 03:58
I can’t reproduce this on 2.7.10 nor 3.4.3, on Arch Linux with Gnu Readline 6.3.008-1. Instead, when I press <Tab><Tab>, I see the y or n query printed, but it is immediately followed by all the possibilities (as if I said Y) without any chance to actually enter Y or N or hit Ctrl+C.
msg252909 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-10-13 04:01
FWIW the “Display all possibilities” prompt works properly in Bash, so maybe I have a separate bug somewhere which is masking Serhiy’s bug.
msg252915 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-10-13 05:27
I can't reproduce original behavior anymore. In 3.4+ <Tab> at the begin of the line inserts the tabulation character. In 2.7 and 3.3- double <Tab> causes the behavior described by Martin.

Yes, please open new issue about the “Display all possibilities” prompt Martin.
msg255528 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-28 05:01
Discovered Issue 22923 is already open about “Display all possibilities” problem. It sounds like that may be a regression in Readline, not Python.
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60355
2016-03-22 15:08:10serhiy.storchakasetstatus: open -> closed
resolution: out of date
stage: test needed -> resolved
2015-11-28 06:25:51serhiy.storchakasetdependencies: + No prompt for "display all X possibilities" on completion-enabled input()
2015-11-28 05:01:21martin.pantersetmessages: + msg255528
2015-10-13 05:27:07serhiy.storchakasetmessages: + msg252915
2015-10-13 04:01:36martin.pantersetmessages: + msg252909
2015-10-13 03:58:04martin.pantersetnosy: + martin.panter

messages: + msg252908
stage: test needed
2012-11-01 20:32:10serhiy.storchakasetmessages: + msg174472
2012-10-16 13:06:57serhiy.storchakasetmessages: + msg173039
2012-10-16 12:44:51amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg173037
2012-10-06 19:32:42serhiy.storchakacreate