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: Eliminate 'ThemeChanged' warning when running IDLE tests
Type: behavior Stage: needs patch
Components: IDLE, Tkinter Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: ned.deily, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2016-06-03 08:00 by terry.reedy, last changed 2022-04-11 14:58 by admin.

Messages (7)
msg267078 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-03 08:00
When running "python_d.exe -m test_idle from console or when running test file from IDLE after starting it in either console or by import, the following sometimes appears.

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"

Serhiy, this is pobably not critical, but it is annoying.  Perhaps the 'kill-callbacks' patch would fix this.  Still, I try to have IDLE tests cleanup properly.

Known repeatable occurrences:
* test_configdialog.ConfigDialogTest.test_dialog, when run from IDLE after import, but not when part of suite.
* test_replace.ReplaceDialogTest.test_default_command, 3 times, when run as part suite, but not when run from IDLE after import.
msg267081 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-03 08:14
This looks as a duplicate of issue20567.
msg267226 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-04 03:58
New changeset 0207c6203f84 by Terry Jan Reedy in branch '3.5':
Issue #27196: Stop 'application destroyed' warnings when running IDLE tests.
https://hg.python.org/cpython/rev/0207c6203f84

New changeset 2d864ac472f0 by Terry Jan Reedy in branch 'default':
Merge issue #27196 from 3.5: Stop IDLE test 'application destroyed' warnings.
https://hg.python.org/cpython/rev/2d864ac472f0
msg267228 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-04 04:17
I closed #20567 after finishing what I intended to do 3 years ago.  I decided make this a separate issue for trying Serhiy's suggestion of updata_idletasks.  Pursuing 'no default root' is #24137.

3 other files also gave the warning, once, when run alone.  2 of the 4 'warned with the test suite in 3.5 and 3 of 4 in 3.6.  Adding root.update or root.update_idletasks to all 4 fixed all warnings I know of for both versions. It appears to be a coincidence that the warnings consistently appeared where they did.  I also added a note about this fix to README.txt.  

There is no known problem in 2.7.  I fixed 3.5 also because the warnings sometimes appear in buildbot reports, and they don't need the noise.
msg268861 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-19 17:43
FWIW, I'm still seeing these errors on OS X (10.11.5 with ActiveTcl 8.5.18) using 2.7.12rc1, 3.5.2rc1, and top-of-trunk 3.6.0.  They do not occur on the same platform when using 2.7.11 or 3.5.1.

For example:
$ /usr/local/bin/python2.7
Python 2.7.12rc1 (v2.7.12rc1:13912cd1e7e8, Jun 11 2016, 15:32:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin [...]
$ /usr/local/bin/python2.7 -m test.regrtest -ugui -j3 test_idle
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"
[1/1] test_idle
1 test OK.

$ /usr/local/bin/python3.5
Python 3.5.2rc1 (v3.5.2rc1:68feec6488b2, Jun 11 2016, 21:59:53)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin [...]
$ /usr/local/bin/python3.5 -m test.regrtest -ugui test_idle
[1/1] test_idle
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"
1 test OK.

$ ./bin/python3.6
Python 3.6.0a2+ (default, Jun 19 2016, 13:19:06)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin [...]
$ ./bin/python3.6 -m test -ugui -j3 test_idle
Run tests in parallel using 3 child processes
0:00:02 [1/1] test_idle passed
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"
1 test OK.
Total duration: 0:00:03
msg269089 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-22 21:47
The only thing I still see is a pair of ThemeChanged warnings from 2.7.  Using binary search, I identified test_editmenu as the culprit.  This in spite of all the cleanup I can think of

    @classmethod
    def tearDownClass(cls):
        del cls.text, cls.entry, cls.spin
        cls.root.clipboard_clear()
        cls.root.update_idletasks()
        cls.root.update()
        cls.root.destroy()
        del cls.root

When I tried to determine which test method(s) gave the warning, as disable all to make sure the warnings vanished, which then did.  But after re-enabling, the warnings did not come back -- until they did after a few more runs.  I suspect that the only permanent solution will be Serhiy's patch to have .destroy cancel pending callbacks.
msg359559 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-01-07 22:42
2.7 EOL.

Ned, do you still see Themed Changed?  I don't on 3.8 on Macbook. with 10.14 mohave(?)
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71383
2020-01-07 22:42:55terry.reedysetmessages: + msg359559
versions: + Python 3.9, - Python 2.7, Python 3.5, Python 3.6
2016-06-22 21:47:44terry.reedysetmessages: + msg269089
2016-06-19 17:43:09ned.deilysetstatus: closed -> open

versions: + Python 2.7, Python 3.5
nosy: + ned.deily

messages: + msg268861
resolution: fixed ->
stage: resolved -> needs patch
2016-06-04 04:17:47terry.reedysetstatus: open -> closed
messages: + msg267228

assignee: terry.reedy
resolution: fixed
stage: needs patch -> resolved
2016-06-04 03:58:55python-devsetnosy: + python-dev
messages: + msg267226
2016-06-03 08:14:30serhiy.storchakasetmessages: + msg267081
2016-06-03 08:00:06terry.reedycreate