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

[2.7] test_ttk_guionly doesn't destroy all widgets on Python 2.7 #75318

Closed
vstinner opened this issue Aug 8, 2017 · 12 comments
Closed

[2.7] test_ttk_guionly doesn't destroy all widgets on Python 2.7 #75318

vstinner opened this issue Aug 8, 2017 · 12 comments
Labels
3.7 (EOL) end of life performance Performance or resource usage topic-tkinter

Comments

@vstinner
Copy link
Member

vstinner commented Aug 8, 2017

BPO 31135
Nosy @vstinner, @serhiy-storchaka
PRs
  • bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3025
  • [2.7] bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3026
  • [3.6] bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method (#3025) #3030
  • Files
  • widget_instance.patch
  • fix_destroy.patch
  • widget_instance-master.patch
  • widget_instance-2.7-v2.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 = None
    closed_at = <Date 2017-08-10.15:03:03.647>
    created_at = <Date 2017-08-08.00:46:39.117>
    labels = ['3.7', 'expert-tkinter', 'performance']
    title = "[2.7] test_ttk_guionly doesn't destroy all widgets on Python 2.7"
    updated_at = <Date 2017-08-10.15:03:03.644>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-08-10.15:03:03.644>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-08-10.15:03:03.647>
    closer = 'vstinner'
    components = ['Tkinter']
    creation = <Date 2017-08-08.00:46:39.117>
    creator = 'vstinner'
    dependencies = []
    files = ['47061', '47062', '47063', '47064']
    hgrepos = []
    issue_num = 31135
    keywords = ['patch']
    message_count = 12.0
    messages = ['299880', '299881', '299899', '299902', '299913', '299914', '299915', '299916', '299938', '299940', '299977', '300097']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'gpolo', 'serhiy.storchaka']
    pr_nums = ['3025', '3026', '3030']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue31135'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    While working on bpo-31068, I wrote attached widget_instance.patch to check if test_ttk_guionly really removes all widgets. Bad news: it doesn't. Example:

    haypo@selma$ ./python -m test -u all test_ttk_guionly
    (...)
    test test_ttk_guionly crashed -- <type 'exceptions.Exception'>: leaking 69 widgets
    (...)

    Attached fix_destroy.patch is my attempt to fix this issue.

    @vstinner vstinner added topic-tkinter performance Performance or resource usage labels Aug 8, 2017
    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    I only tested Python 2.7. I didn't check if other branches are affected.

    @vstinner vstinner changed the title test_ttk_guionly doesn't destroy all widgets [2.7] test_ttk_guionly doesn't destroy all widgets on Python 2.7 Aug 8, 2017
    @serhiy-storchaka
    Copy link
    Member

    See bpo-25130. Maybe forcing garbage collecting will help.

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    My widget_instance.patch calls test_support.gc_collect() and removes all
    widgets from the root window. It's not enough. That's why I proposed to modify LabeledScale.destroy().

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    On master, LabeledScaleTest.test_initialization() leaks a widget in the root widget, even after root.destroy(). The problem is that LabeledScaleTest.__del__() doesn't call Frame.destroy(self) if self._variable is not set. So master has at least this bug.

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    widget_instance-master.patch: Check that Tkinter.Widget.destroy() removes all children and check that test_ttk_guionly doesn't leak widgets.

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    Example of failure on master using widget_instance-master.patch:

    haypo@selma$ ./python -m test -v -u all test_ttk_guionly

    ======================================================================
    ERROR: test_initialization (tkinter.test.test_ttk.test_extensions.LabeledScaleTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/haypo/prog/python/master/Lib/tkinter/test/test_ttk/test_extensions.py", line 14, in tearDown
        super().tearDown()
      File "/home/haypo/prog/python/master/Lib/tkinter/test/support.py", line 40, in tearDown
        w.destroy()
      File "/home/haypo/prog/python/master/Lib/tkinter/__init__.py", line 2305, in destroy
        % self.children)
    Exception: destroy() doesn't clear all children: {'!labeledscale2': <tkinter.ttk.LabeledScale object .!frame.!labeledscale2>}

    My #3025 PR fixes LabeledScale and OptionMenu destroy() method in the master branch.

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    widget_instance-2.7-v2.patch: Updated patch for Python 2.7 to debug test_ttk_guionly.

    #3026 fix LabeledScale and OptionMenu destroy() method for Python 2.7.

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    New changeset 56e162a by Victor Stinner in branch '2.7':
    ttk: fix LabeledScale and OptionMenu destroy() method (bpo-3026)
    56e162a

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 8, 2017

    New changeset cd7e9c1 by Victor Stinner in branch 'master':
    ttk: fix LabeledScale and OptionMenu destroy() method (bpo-3025)
    cd7e9c1

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 9, 2017

    New changeset 33460fa by Victor Stinner in branch '3.6':
    ttk: fix LabeledScale and OptionMenu destroy() method (bpo-3025) (bpo-3030)
    33460fa

    @vstinner
    Copy link
    Member Author

    Copy of interesting comments: #3025

    serhiy-storchaka: "Parent's destroy() now is called even if this destroy() already was called. I.e. it can be called twice."

    haypo: "Yes, it's a deliberate choice. All other ttk widgets now have the same behaviour."

    --

    Ok, the bug is now fixed in 2.7, 3.6 and 3.7 (master) branches. I close the issue.

    @vstinner vstinner added the 3.7 (EOL) end of life label Aug 10, 2017
    @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
    3.7 (EOL) end of life performance Performance or resource usage topic-tkinter
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants