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.

Title: Version 3.2.3 IDLE CTRL-Z plus Carriage Return to end does not work
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.3, Python 3.4, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, r.david.murray, roger.serwy, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2012-05-05 21:15 by ewodrich, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
ctrl_z_doc.patch roger.serwy, 2012-05-08 22:55 remove "(this is Control-z on Windows)." from help.txt review
ctrl_z_doc_rev1.patch roger.serwy, 2013-04-11 04:46 review
Messages (8)
msg160042 - (view) Author: Ed Wodrich (ewodrich) Date: 2012-05-05 21:15

I am a brand new user attempting to learn Python.  I downloaded and installed the .msi installer version 3.2.3 on May 5, 2012.  I am running Windows XP SP2 32-bit on a Pentium 4.  I opted to load all features of the program.  Installation finished without any errors.

Admittedly, despite previous programming experience with other languages, I have a lot to learn.  What I saw when I tried using the IDLE was that it would not end with ctrl-Z followed by carriage return.  Using either quit() and replying to the dialog or using ctrl-d followed by carriage return worked.  I am submitting this because the GUI interface and what documentation I have seen so far states that ctrl-z followed by carriage return is the method to use in Windows.  

IMHO possible fix options (presuming this is not something weird because I don't know what I am doing yet) would be to update the documentation for consistency or to change the behavior of the IDLE?

Thank you, in advance, for your efforts with regard to this issue.

Best Regards,

msg160116 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-05-07 01:56
Making idle work with ctl-Z+enter might be reasonable.

However, can you describe more fully the documentation that led you believe that would work?  ctl-Z+enter is for the CMD window, not IDLE, to my understanding.
msg160117 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-05-07 04:12
Using ^Z (ascii Substitute char) instead of ^D (ascii 'End of Transmission') is an MSDOS affectation carried over to the the MSDOS-based text-mode Command Prompt on Windows.

I verified that ^D now closes IDLE on Windows. ^Z gives a beep.
(I do not know about 2.7. It needs to be checked.)
I also see that the IDLE Help document still says
"Control-d sends end-of-file; closes window if typed at >>> prompt
(this is Control-z on Windows)." so you are right to be confused.

I do not know when the change was made, but I presume it was intentional as ^D is standard and most Windows users have no experience with MSDOS and ^Z. (It does not close Windows gui applications that I know of, nor does ^D usually.) So my inclination is to just remove the note (after checking 2.7.3 behavior) and not change the code.
msg160180 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-05-08 01:07
Ctrl+Z followed by Return still exits the Python shell on the command prompt under Vista.

The simplest way to get this behavior working in IDLE would be modifying the end-of-file definition in config-keys.def, but only for the Windows keymap:

    [IDLE Classic Windows]
    # truncated
    end-of-file=<Control-Key-d> <Control-Key-D> <Control-Key-z><Return>
    # truncated

I left the Ctrl+D bindings in place, as these are IDLE's "norm". In a strict sense they should be removed for a Windows key map. (I am basing my cross-platform understanding of Ctrl+Z from here: )

The undo functionality already binds to Ctrl+Z. By using the Ctrl+Z and Return sequence to signal IDLE's shell to exit, I can foresee users accidentally closing their shells. Consider this scenario: a user types a long command and the prompt and then presses Ctrl+Z to undo the last few key strokes. The user then presses enter to run the command but the shell closes instead. The regular python shell from a command prompt displays a "^Z" as a visual indicator. If IDLE's shell did the same then I would not have hesitations about changing the key bindings.

For now, I'm in favor of changing the documentation in help.txt to omit "(this is Control-z on Windows)."
msg186546 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-11 04:46
Attached is a refreshed patch for tip.

Supporting Ctrl+Z and Enter on Windows would be problematic as I discussed earlier. We could introduce a timer to make sure Enter is pressed within a short window after Ctrl+Z. 

If someone wants to make a patch for that, I'll gladly review it. In the meantime, changing the docs to reflect the actual behavior of IDLE would be simpler.
msg186702 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-04-13 09:13
msg187144 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-04-17 05:28
New changeset f2a744e067e0 by Roger Serwy in branch '2.7':
#14735: Update IDLE docs to omit "Control-z on Windows".

New changeset 017891cc973f by Roger Serwy in branch '3.3':
#14735: Update IDLE docs to omit "Control-z on Windows".

New changeset 3fda81465102 by Roger Serwy in branch 'default':
#14735: merge with 3.3.
msg187145 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-17 05:30
I am closing this issue as fixed since the documentation now matches the behavior of IDLE.
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58940
2013-04-17 05:30:27roger.serwysetstatus: open -> closed
2013-04-17 05:30:16roger.serwysetresolution: fixed
messages: + msg187145
stage: patch review -> resolved
2013-04-17 05:28:01python-devsetnosy: + python-dev
messages: + msg187144
2013-04-13 09:13:46serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg186702
2013-04-11 04:46:58roger.serwysetfiles: + ctrl_z_doc_rev1.patch
versions: + Python 3.4, - Python 3.2
messages: + msg186546

type: behavior -> enhancement
stage: patch review
2012-05-08 22:55:20roger.serwysetfiles: + ctrl_z_doc.patch
keywords: + patch
2012-05-08 01:07:36roger.serwysetmessages: + msg160180
2012-05-07 04:12:39terry.reedysetnosy: + roger.serwy

messages: + msg160117
versions: + Python 2.7, Python 3.3
2012-05-07 01:56:03r.david.murraysetnosy: + r.david.murray, terry.reedy
messages: + msg160116
2012-05-05 21:32:33ewodrichsetnosy: - ewodrich
-> (no value)
2012-05-05 21:15:00ewodrichcreate