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: IDLE - remove debugger 'interacting'
Type: behavior Stage: commit review
Components: IDLE Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: markroseman, terry.reedy
Priority: normal Keywords: patch

Created on 2012-07-13 19:32 by roger.serwy, last changed 2022-04-11 14:57 by admin.

File name Uploaded Description Edit
fix-nested-mainloop.patch markroseman, 2015-09-22 22:42 review
remove-interacting-debugger.patch markroseman, 2015-09-25 21:06
Messages (11)
msg165410 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-07-13 19:32
IDLE fails to close if the debugger was active.

Steps to reproduce:

1) Start IDLE with only a shell.
2) Enable debugger.
3) Press enter in the shell. (Causes debugger to activate)
4) Close the shell window. (File->Exit or click X)
5) Click "OK" in the dialog box.

IDLE keeps running despite all windows being closed.
msg221948 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-30 08:46
A pythonw.exe process is left running if I try this with 3.4.1 on Windows 7.
msg228252 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-02 19:30
A few years ago there was an issue where starting a new user process left the old user process continuing as a zombie. This time, it seems to be the idle process that becomes the zombie.  I determined this by starting Idle in edit-only mode, noting the memory size of the one process, running the shell, which starting a smaller user process, closing the editor, and continuing with the reproduce steps.  The larger Idle process remained. However, 'Idle' is gome from the Task Manager Application tab.

Saimadhav (or Mark) can you run the experiment on Linux and /or Mac and report a bit more?

The box says "The program is still running.  Do you want to kill it."  I am pretty sure 'the program' refers to the user process, not the Idle process.  (The message should be clearer about this.)

The message box is called in PyShell.PyShell.close (986 in 3.4.1).  If not 'Cancel', the call sequence is EditorWindow.EditorWindow.close, PyShell._close, Editor._close. PyShell._close first calls self.close_debugger.  That ends with 'Debug Off' and a new '>>> '.  I see these printed before Shell disappears.

If step 3 is omitted, there is no problem.  If I add 3b) Close the debugger, there is still a problem.  So 'activating' the debugger does something that is not undone by closing the debugger and that obstructs closing.
msg228275 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-02 22:42
#21339, closed as a duplicate of this, has a traceback might be helpful.
msg250342 - (view) Author: Mark Roseman (markroseman) * Date: 2015-09-09 23:15 has a nested call to mainloop() ... which is almost always a bad idea. I'm betting the close is being handled in this mainloop, and there are no more events being generated, meaning the real mainloop towards the bottom of PyShell (which checks if we've got open windows) is never being reentered. 

Will try to look at this closer, but in case anyone has a chance in the interim...
msg251359 - (view) Author: Mark Roseman (markroseman) * Date: 2015-09-22 22:42
Figured out the cause of this hang, it was to do with the nested event loops.

It turns out that mainloop() really should just be for the mainloop. Or at least quit() should only be used to quit the outer loop, as it relies on setting a static variable, so is not reentrant, i.e. does not handle nested event loops.

I changed the nested loop to use a different mechanism to start the nested event loop (vwait, which waits for a tcl variable to be set) and terminate the nested loop (setting that variable). Have attached fix-nested-mainloop.patch.

Fixes the problem here, and in #15348, and another case I was using (start, enable debugger, open module, run module, quit).

The one in #24455 is something different, I'll look into it.
msg251401 - (view) Author: Mark Roseman (markroseman) * Date: 2015-09-23 03:42
See #24455 for a patch that includes the changes from this one as well as some additional changes that fixes that bug.
msg251613 - (view) Author: Mark Roseman (markroseman) * Date: 2015-09-25 21:06
Doing some testing using "-n". Various close/quit scenarios are either disallowed or broken as it turns out. I found that removing the "interacting" check on close improved the matter quite substantially, so that I could quit when the debugger was sitting waiting for input, without hangs etc.

Have attached remove-interacting-debugger.patch (which can be applied on top of fix-mainloop2.patch (from #24455, which includes the changes in fix-nested-mainloop.patch for this bug).
msg255034 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-11-21 01:24
See #15348 for result of fix-mainloop2.patch on Windows.
msg255037 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-11-21 01:46
Git patch does not apply because header does not have full paths.

diff --git a/ b/
index e2014d1..9efe6fa 100644
--- a/
+++ b/


diff -r ed694938c61a Lib/idlelib/
--- a/Lib/idlelib/	Tue Sep 22 13:08:42 2015 +0300
+++ b/Lib/idlelib/	Tue Sep 22 20:36:09 2015 -0700

This is also why no *review* link after the *edit* link on right.
I will go ahead and manually edit the file.
msg352808 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-09-19 17:23
fix-nested-mainloop.patch was superceded by fix-nested2.patch for #24455.
I verified that the initial test now passes.  When I click 'yes' in that box popped up by step 4, both Shell and debugger windows disappear and IDLE exists.

The only question left is whether to apply remove-interacting-debugger.patch, which was aimed at the deprecated but not removed -n mode.
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59552
2019-09-19 17:23:29terry.reedysetnosy: - roger.serwy, Saimadhav.Heblikar
title: IDLE - does not close if the debugger was active -> IDLE - remove debugger 'interacting'
messages: + msg352808

versions: + Python 3.9, - Python 2.7, Python 3.4, Python 3.5, Python 3.6
2019-02-24 22:17:04BreamoreBoysetnosy: - BreamoreBoy
2015-11-21 01:46:30terry.reedysetassignee: terry.reedy
stage: commit review
messages: + msg255037
versions: + Python 3.6
2015-11-21 01:24:34terry.reedysetmessages: + msg255034
2015-09-25 21:06:22markrosemansetfiles: + remove-interacting-debugger.patch

messages: + msg251613
2015-09-23 03:42:21markrosemansetmessages: + msg251401
2015-09-22 22:42:02markrosemansetfiles: + fix-nested-mainloop.patch
keywords: + patch
messages: + msg251359
2015-09-09 23:15:38markrosemansetmessages: + msg250342
2015-09-03 21:32:10markrosemansetnosy: + markroseman
2014-10-02 22:42:47terry.reedysetmessages: + msg228275
2014-10-02 19:30:50terry.reedysetnosy: + Saimadhav.Heblikar
messages: + msg228252
2014-06-30 08:46:58BreamoreBoysetnosy: + terry.reedy, BreamoreBoy

messages: + msg221948
versions: + Python 3.4, Python 3.5, - Python 3.2, Python 3.3
2012-07-13 19:32:43roger.serwycreate