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: Force not using _default_root in IDLE
Type: enhancement Stage: resolved
Components: IDLE, Tkinter Versions: Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: kbk, martin.panter, python-dev, roger.serwy, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2015-05-06 15:26 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
nodefaultroot.diff terry.reedy, 2016-06-20 09:04 review
nodefaultroot2.diff serhiy.storchaka, 2016-06-20 14:29 review
nodefaultroot3.diff terry.reedy, 2016-06-21 09:38 review
nodefaultroot4.diff terry.reedy, 2016-06-21 21:22 review
Messages (15)
msg242680 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-06 15:26
Perhaps explicitly calling NoDefaultRoot() in IDLE will help to catch some possible bugs (in IDLE or in Tkinter). It should be called only when IDLE is ran in subprocess mode, so it will not affect user code that uses Tkinter. _default_root is used mainly for interactive experiments with Tkinter.

It is worth also to call NoDefaultRoot() in IDLE tests (see Tkinter tests as a guide).
msg268873 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-19 21:45
What your thoughts about this Terry?
msg268888 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-20 09:04
Time to do it, at least for tests.  I think patch is ready to push, with running without default root disabled until I do more testing.  In particular, reread in Rietveld, do suggested actions when run through htest, and try all menu items.
msg268901 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-20 14:29
I ran IDLE and tests and found yet few needed changes.

NoDefaultRoot() should be called only if run IDLE with a subprocess support.
msg268902 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-20 14:31
And I thing changes to tests can be applied to all versions (especially since they become diverge), but NoDefaultRoot() should be called in IDLE only in 3.6.
msg268979 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-21 09:38
I made htest run without default root, just list test_idel, and found a few more.  I grepped for 'Toplevel()'.  Also for bad Tk() calls.

I still need to move the call in pyshell and check this over.  But I think it close.
msg269028 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-21 21:22
Conditioned NoDefaultRoot() on use_subprocess.  Ran through menu.  Will push soon after rechecking patches with Rietveld. 

Thanks for the additional review.  I don't know that this caught any real bugs in IDLE itself.  But many of the htests needed upgrading to consistently use a Toplevel with the exiting root as parent (and never start a second mainloop). Not worth backporting en masse though.
msg269033 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-21 22:42
New changeset 064b29dde096 by Terry Jan Reedy in branch 'default':
Issue #24137: Run IDLE, test_idle, and htest with tkinter default root disabled.
msg269254 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-25 20:53
New changeset a8d611eb6173 by Serhiy Storchaka in branch 'default':
Issue #24137: Fixed IDLE on Linux with tkinter default root disabled.
msg269255 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-25 20:54
You have missed my changes in nodefaultroot2.diff.
msg269265 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-25 23:18
Using Rietveld to make a 1-2 diff for each file, it appears you made 3 changes. I incorporated 2, and missed 1 (which you just pushed).  I believe I incorporated your changes by hand because I had already made additional changes myself. I suspect that at that time I failed to middle-click the '1' for 'pyshell' hard enough to get the 1-2 diff for pyshell.  I should have counted and checked to make sure I had all 8 diffs.
msg271207 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-07-25 02:07
It seems this change causes test_tix to fail for me; see Issue 27611
msg271224 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-07-25 04:32
New changeset 5c76f787e695 by Terry Jan Reedy in branch 'default':
Issue #24137, issue #27611: Restore tkinter after test_idle.
msg272821 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-16 04:10
New changeset a6a248479b66 by Terry Jan Reedy in branch 'default':
Issue #27611, #24137: Only change tkinter when easily restored.
msg320530 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-27 02:17
The net effect of this issue:

pyshell.main calls NoDefaultRoot() when running normally, when using a subprocess and testing is not set.  It does not call it when in -n mode since that would affect users.

idle_test.htest  calls NoDefaultRoot() unconditionally.  pyshell.main is not called.

test.test_idle sets testing to avoid the call when run by test.regrtest, to avoid failing the latter's changed-environment check.  But it does call NoDefaultRoot when run as __main__ and the tests are run by unittest.main.

Known dependencies on a default root have been removed.  It is unlikely that any are left.
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68325
2018-06-27 02:17:09terry.reedysetmessages: + msg320530
2016-08-16 04:10:31python-devsetmessages: + msg272821
2016-07-25 04:32:09python-devsetmessages: + msg271224
2016-07-25 02:07:48martin.pantersetnosy: + martin.panter
messages: + msg271207
2016-06-25 23:18:29terry.reedysetmessages: + msg269265
2016-06-25 20:54:09serhiy.storchakasetmessages: + msg269255
2016-06-25 20:53:16python-devsetmessages: + msg269254
2016-06-21 22:43:58terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-06-21 22:42:02python-devsetnosy: + python-dev
messages: + msg269033
2016-06-21 21:22:26terry.reedysetfiles: + nodefaultroot4.diff

messages: + msg269028
2016-06-21 09:38:29terry.reedysetfiles: + nodefaultroot3.diff

messages: + msg268979
2016-06-20 14:31:49serhiy.storchakasetmessages: + msg268902
2016-06-20 14:29:04serhiy.storchakasetfiles: + nodefaultroot2.diff

messages: + msg268901
2016-06-20 09:04:41terry.reedysetfiles: + nodefaultroot.diff
versions: + Python 3.6, - Python 3.5
messages: + msg268888

assignee: terry.reedy
keywords: + patch
stage: needs patch -> patch review
2016-06-19 21:45:33serhiy.storchakasetmessages: + msg268873
stage: needs patch
2015-05-06 15:26:17serhiy.storchakacreate