classification
Title: test_idle causes test_ttk_guionly 'can't invoke "event" command: application has been destroyed' messages from Tk
Type: behavior Stage: resolved
Components: IDLE, Tests, Tkinter Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: andtorg, kbk, ned.deily, python-dev, roger.serwy, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2014-02-08 23:36 by ned.deily, last changed 2016-06-04 06:33 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
issue20567.patch serhiy.storchaka, 2014-02-09 17:21 review
Messages (23)
msg210704 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-08 23:36
Seen with default (3.4.0) framework builds on OS X 10.9 with ActiveTcl 8.5.15.0:

./configure --enable-universalsdk=/ --with-universal-archs=intel --enable-framework=/tmp/t/Library/Frameworks
make && make install
cd /tmp/t
/tmp/t/bin/python3.4 -m test -w -uall
[...]
[343/389/1] test_ttk_guionly
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
[344/389/1] test_ttk_textonly
[...]

When running test_ttk_guionly by itself (or in combination with a few neighboring tests):

  /tmp/t/bin/python3.4 -m test -w -uall test_ttk_guionly

the message is not seen.  I had not seen this behavior prior to somewhere in the 3.4.0 development cycle.
msg210738 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-09 09:47
Could you try test_ttk_guionly after test_all, test_builtins, test_tcl? If the issue is not reproduced, try to use binary search: divide the tests before test_ttk_guionly on to parts, and run tests with one half, then with other. Repeat until found the culprit.
msg210745 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-09 10:43
Threading and subprocess tests also evoke a suspicion.
msg210746 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-09 10:47
$ /usr/local/bin/python3.3 -m test -w -uall test_idle test_ttk_guionly
[1/2] test_idle
[2/2] test_ttk_guionly
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
can't invoke "event" command:  application has been destroyed
    while executing
"event generate $w <<ThemeChanged>>"
    (procedure "ttk::ThemeChanged" line 6)
    invoked from within
"ttk::ThemeChanged"
All 2 tests OK.
msg210749 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-09 11:26
The combination of just test_idle followed by test_ttk_guionly also produces the "application has been destroyed" messages on Debian Linux and when run from a build directory (e.g. not installed) and with 2.7, 3.3, and default.
msg210769 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-02-09 16:30
Ned, do you actually *see* this on 2.7, 3.3? The message looks suspiciously like the somewhat strange 3.4-only shutdown message suppressed by #20167.
msg210772 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-09 17:21
Here is a patch which fixes symptoms. Maybe we'll find better solution.

These messages are produced when the ttk::ThemeChanged command called from a callback for already destroyed Tk root window.
msg210776 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-02-09 18:13
Running just the two tests fails on windows also, with all three versions. For 2.7, test_ttk_guionly is skipped with "test_ttk_guionly skipped -- tk not available: Can't find a usable init.tcl in the following directories:. This in spite of the fact that the idle test just found init.tcl and that the ttk test passes without the idle test running first. This is relatively recent.

Does the test runner not delete modules as they are finished?

I am rebuilding python and will try tests again. If problem persists and patch solves it, I will go ahead and apply.
msg212331 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-02-26 23:59
Patch fixes problem on 3.3. I need to test 2.7 and add a note to idle_test/README that class widget attributes must be deleted because module may not be deleted, at least for a while.
msg212396 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-02-27 23:48
New changeset 43c4073cb2e2 by Terry Jan Reedy in branch '2.7':
Issue #20567: Delete class attribute gui widgets in idle tests.
http://hg.python.org/cpython/rev/43c4073cb2e2

New changeset daf44eb9c54e by Terry Jan Reedy in branch '3.3':
Issue #20567: Delete class attribute gui widgets in idle tests.
http://hg.python.org/cpython/rev/daf44eb9c54e
msg212398 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-02-28 00:09
There is also a different test problem that might be related to the altered environment. See #20800
msg219528 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-01 21:45
Probably still need to add note to idle_test/README.txt.
msg221467 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-24 15:16
I recently saw the same message when developing an individual idle_test module on repository debug builds even though all class attributes were being deleted. One was an Idle EditorWindow. I solved the problem by deleting the class attributes other than root before root.destroy. I should recheck all modules/classes with attributes other than root.
msg226217 - (view) Author: Andrea Torre (andtorg) Date: 2014-09-01 08:29
Ubuntu 12.04 64-bit
Python 2.7.3 (virtualenv)

Hi, just adding a few info, hope not completely useless, that seem related to the issue. I got the same message when running nosetests against my source. It's an application using Tkinter as frontend. All tests pass, though. Besides, I always destroy root in tearDown(). 

I noticed that the the issue only comes up when i run tests without specifying any path, like in nosetests -vs.

If i enter nosetests -vs tests/unit/ tests/integration/ everything runs smooth.
msg229182 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-10-12 17:22
These messages are produced because there are non-handled events of destroyed root widget. They are handled when update() is called for other root widget. To get rid of them you should call update_idletasks() before destroying root widget.
msg229201 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-12 22:17
You left this issue number off your tkinter test updates, such as f6f098bdb843.  By using .update_idletasks instead of .update, are you assuming that their are no user events, or that they should be ignormed?

I was wondering whether it would be Ok, if not a good idea, to run tests, and maybe Idle itself, with NoDefaultRoot.  I see that is already done for tkinter tests. I cannot use exactly the same design as AbstractTkTest since I sometimes do other things in setUp/tearDownClass, but I could define create_test_root() and delete_test_root() functions in a support file.
msg229224 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-10-13 07:15
> You left this issue number off your tkinter test updates, such as
> f6f098bdb843.

This is minor change. Actually, it should be done yet in issue22236, I had 
just missed it, because these warnings was produced only in 2.7.

> By using .update_idletasks instead of .update, are you
> assuming that their are no user events, or that they should be ignormed?

There are not only "user" events. When you create or configure some widgets, 
some actions is not executed immediately (in particular changing a theme), but 
they are deferred to the next call of update() or update_idletasks(). When you 
call update_idletasks(), these harmless events are quickly handled without 
errors. This is only known me way to clear events queue.

> I was wondering whether it would be Ok, if not a good idea, to run tests,
> and maybe Idle itself, with NoDefaultRoot.

I support it. There are some places in IDLE or tests which should be fixed, 
they are used default master.

> I cannot use exactly the same design as AbstractTkTest since
> I sometimes do other things in setUp/tearDownClass, but I could define
> create_test_root() and delete_test_root() functions in a support file.

See Lib/tkinter/test/test_tkinter/test_images.py. Image tests do  other things 
in setUpClass/tearDownClass, but calls parent's method too.
msg267116 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-03 17:33
New changeset 8090931ba850 by Terry Jan Reedy in branch '2.7':
Issue 20567: Revise idle_test/README.txt and some tests to match new advice.
https://hg.python.org/cpython/rev/8090931ba850
msg267117 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-03 17:42
This and the followup for 3.x full the TODOs in msg219528, revise README.txt, and in msg221467, change delete order to match new advice.  

This issue was about conflict between test_idle and test_ttk-guionly and that has apparently been solved. After the 3.x commit, I will close this and follow up on the 'update before destroy' and 'prohibit default root' ideas on #27196.
msg267223 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-04 02:28
New changeset 813bb6a4c693 by Terry Jan Reedy in branch '3.5':
Issue 20567: Revise idle_test/README.txt and some tests to match new advice.
https://hg.python.org/cpython/rev/813bb6a4c693

New changeset d8e5e3da4d57 by Terry Jan Reedy in branch 'default':
Issue 20567: Revise idle_test/README.txt and some tests to match new advice.
https://hg.python.org/cpython/rev/d8e5e3da4d57
msg267227 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-04 04:15
Using update_idletasks msg229182 is #27196; it succeeded in stopping ThemeChanged warnings.  Using 'no-default-root' msg229201 is #24137.
msg267230 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-04 05:17
-To avoid interfering with other GUI tests, all GUI objects must be
+To avoid interfering with other gui tests, all gui objects must be destroyed and

Why "gui" is in lower case?
msg267237 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-04 06:33
Because I copied from 2.7, which had not been corrected from what I wrote years ago before we started being more consistent and correct.  Fixed in all 3 versions.
History
Date User Action Args
2016-06-04 06:33:38terry.reedysetmessages: + msg267237
2016-06-04 05:17:56serhiy.storchakasetmessages: + msg267230
2016-06-04 04:15:54terry.reedysetmessages: + msg267227
2016-06-04 02:31:15terry.reedysetstatus: open -> closed
stage: needs patch -> resolved
resolution: fixed
versions: + Python 3.6
2016-06-04 02:28:24python-devsetmessages: + msg267223
2016-06-03 17:42:04terry.reedysetmessages: + msg267117
2016-06-03 17:33:34python-devsetmessages: + msg267116
2014-10-13 07:15:53serhiy.storchakasetmessages: + msg229224
2014-10-12 22:17:44terry.reedysetmessages: + msg229201
2014-10-12 17:22:27serhiy.storchakasetmessages: + msg229182
2014-09-01 09:50:47terry.reedysetversions: + Python 3.4, Python 3.5
2014-09-01 08:29:49andtorgsetnosy: + andtorg

messages: + msg226217
versions: - Python 3.4, Python 3.5
2014-06-24 15:16:31terry.reedysetmessages: + msg221467
2014-06-01 21:45:28terry.reedysetstage: commit review -> needs patch
messages: + msg219528
versions: + Python 3.5, - Python 3.3
2014-02-28 00:09:17terry.reedysetmessages: + msg212398
stage: needs patch -> commit review
2014-02-27 23:48:51python-devsetnosy: + python-dev
messages: + msg212396
2014-02-26 23:59:28terry.reedysetassignee: terry.reedy
messages: + msg212331
2014-02-09 18:13:05terry.reedysetmessages: + msg210776
2014-02-09 17:21:00serhiy.storchakasetfiles: + issue20567.patch
keywords: + patch
messages: + msg210772
2014-02-09 16:30:46terry.reedysetmessages: + msg210769
2014-02-09 14:08:17serhiy.storchakasetnosy: + terry.reedy, kbk, roger.serwy
type: behavior
components: + IDLE
2014-02-09 11:26:04ned.deilysetmessages: + msg210749
title: test_ttk_guionly gets 'can't invoke "event" command: application has been destroyed' messages from Tk -> test_idle causes test_ttk_guionly 'can't invoke "event" command: application has been destroyed' messages from Tk
2014-02-09 11:09:29ned.deilysetversions: + Python 2.7
2014-02-09 10:59:13ned.deilysetversions: + Python 3.3
2014-02-09 10:47:50ned.deilysetmessages: + msg210746
2014-02-09 10:43:48serhiy.storchakasetmessages: + msg210745
2014-02-09 09:47:12serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg210738
2014-02-08 23:36:18ned.deilycreate