Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_idle causes test_ttk_guionly 'can't invoke "event" command: application has been destroyed' messages from Tk #64766

Closed
ned-deily opened this issue Feb 8, 2014 · 23 comments
Assignees
Labels
tests Tests in the Lib/test dir topic-IDLE topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@ned-deily
Copy link
Member

BPO 20567
Nosy @terryjreedy, @kbkaiser, @ned-deily, @serwy, @serhiy-storchaka
Files
  • issue20567.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-06-04.02:31:15.370>
    created_at = <Date 2014-02-08.23:36:17.984>
    labels = ['tests', 'expert-IDLE', 'type-bug', 'expert-tkinter']
    title = 'test_idle causes test_ttk_guionly \'can\'t invoke "event" command: application has been destroyed\' messages from Tk'
    updated_at = <Date 2016-06-04.06:33:38.211>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2016-06-04.06:33:38.211>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-06-04.02:31:15.370>
    closer = 'terry.reedy'
    components = ['IDLE', 'Tests', 'Tkinter']
    creation = <Date 2014-02-08.23:36:17.984>
    creator = 'ned.deily'
    dependencies = []
    files = ['34011']
    hgrepos = []
    issue_num = 20567
    keywords = ['patch']
    message_count = 23.0
    messages = ['210704', '210738', '210745', '210746', '210749', '210769', '210772', '210776', '212331', '212396', '212398', '219528', '221467', '226217', '229182', '229201', '229224', '267116', '267117', '267223', '267227', '267230', '267237']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'kbk', 'ned.deily', 'roger.serwy', 'python-dev', 'serhiy.storchaka', 'andtorg']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20567'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @ned-deily
    Copy link
    Member Author

    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.

    @ned-deily ned-deily added topic-tkinter tests Tests in the Lib/test dir labels Feb 8, 2014
    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    Threading and subprocess tests also evoke a suspicion.

    @ned-deily
    Copy link
    Member Author

    $ /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.

    @ned-deily
    Copy link
    Member Author

    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.

    @ned-deily ned-deily changed the 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 Feb 9, 2014
    @serhiy-storchaka serhiy-storchaka added topic-IDLE type-bug An unexpected behavior, bug, or error labels Feb 9, 2014
    @terryjreedy
    Copy link
    Member

    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 bpo-20167.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy terryjreedy self-assigned this Feb 26, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 27, 2014

    New changeset 43c4073cb2e2 by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-20567: Delete class attribute gui widgets in idle tests.
    http://hg.python.org/cpython/rev/daf44eb9c54e

    @terryjreedy
    Copy link
    Member

    There is also a different test problem that might be related to the altered environment. See bpo-20800

    @terryjreedy
    Copy link
    Member

    Probably still need to add note to idle_test/README.txt.

    @terryjreedy
    Copy link
    Member

    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.

    @andtorg
    Copy link
    Mannequin

    andtorg mannequin commented Sep 1, 2014

    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.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    You left this issue number off your tkinter test updates, such as
    f6f098bdb843.

    This is minor change. Actually, it should be done yet in bpo-22236, 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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 3, 2016

    New changeset 8090931ba850 by Terry Jan Reedy in branch '2.7':
    bpo-20567: Revise idle_test/README.txt and some tests to match new advice.
    https://hg.python.org/cpython/rev/8090931ba850

    @terryjreedy
    Copy link
    Member

    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 bpo-27196.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 4, 2016

    New changeset 813bb6a4c693 by Terry Jan Reedy in branch '3.5':
    bpo-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':
    bpo-20567: Revise idle_test/README.txt and some tests to match new advice.
    https://hg.python.org/cpython/rev/d8e5e3da4d57

    @terryjreedy
    Copy link
    Member

    Using update_idletasks msg229182 is bpo-27196; it succeeded in stopping ThemeChanged warnings. Using 'no-default-root' msg229201 is bpo-24137.

    @serhiy-storchaka
    Copy link
    Member

    -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?

    @terryjreedy
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir topic-IDLE topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants