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

IDLE: problems with completions on Mac #85777

Closed
rhettinger opened this issue Aug 21, 2020 · 21 comments
Closed

IDLE: problems with completions on Mac #85777

rhettinger opened this issue Aug 21, 2020 · 21 comments
Assignees
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-mac topic-IDLE

Comments

@rhettinger
Copy link
Contributor

BPO 41611
Nosy @rhettinger, @terryjreedy, @ronaldoussoren, @vstinner, @taleinat, @ned-deily, @serhiy-storchaka, @miss-islington
PRs
  • bpo-41611: IDLE: fix freezing on completion on macOS #26400
  • [3.10] bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400) #26401
  • [3.9] bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400) #26402
  • bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() #26404
  • [3.10] bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404) #26419
  • [3.9] bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404) #26420
  • 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 2021-06-12.04:48:58.260>
    created_at = <Date 2020-08-21.17:51:37.650>
    labels = ['OS-mac', 'expert-IDLE', '3.9', '3.10', '3.11']
    title = 'IDLE: problems with completions on Mac'
    updated_at = <Date 2021-06-12.04:48:58.260>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2021-06-12.04:48:58.260>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2021-06-12.04:48:58.260>
    closer = 'terry.reedy'
    components = ['IDLE', 'macOS']
    creation = <Date 2020-08-21.17:51:37.650>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41611
    keywords = ['patch']
    message_count = 21.0
    messages = ['375764', '375767', '375768', '375769', '380925', '394508', '394523', '394527', '394528', '394530', '394531', '394543', '394544', '394546', '394587', '394591', '394634', '394635', '394636', '394637', '395676']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'terry.reedy', 'ronaldoussoren', 'vstinner', 'taleinat', 'ned.deily', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['26400', '26401', '26402', '26404', '26419', '26420']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue41611'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @rhettinger
    Copy link
    Contributor Author

    In case it is helpful, here is the error log from a recent full-day IDLE session.

    $ python3.9 --version
    Python 3.9.0rc1
    $ python3.9 -m idlelib.idle
    Exception in Tkinter callback
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1885, in __call__
        return self.func(*args)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/autocomplete_w.py", line 248, in winconfig_event
        acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1291, in winfo_width
        self.tk.call('winfo', 'width', self._w))
    _tkinter.TclError: bad window path name ".!listedtoplevel4.!frame.text.!toplevel2"
    /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown
      warnings.warn('resource_tracker: There appear to be %d '
    2020-08-20 15:00:38.074 Python[1512:2706287] WARNING: <NSOpenPanel: 0x7ff5a3ed6280> running implicitly; please run panels using NSSavePanel rather than NSApplication.
    2020-08-20 16:29:29.880 Python[1512:2706287] WARNING: <NSOpenPanel: 0x7ff5a25566b0> running implicitly; please run panels using NSSavePanel rather than NSApplication.

    @rhettinger rhettinger added the 3.9 only security fixes label Aug 21, 2020
    @rhettinger rhettinger added topic-IDLE 3.9 only security fixes labels Aug 21, 2020
    @terryjreedy
    Copy link
    Member

    The Mac-specific shutdown warning from multiprocessing is not directly related to IDLE. 'multiprocessing' is not imported by IDLE and is not in sys.modules when IDLE starts.

    From 'all-day' I assume that there was a time period between starting IDLE and getting the traceback.

    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/init.py", line 1885, in __call__
    return self.func(*args)

    __call__ here is a method of CallWrapper, often used for event handlers.

    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/autocomplete_w.py", line 248, in winconfig_event
    acw_width, acw_height = acw.winfo_width(), acw.winfo_height()

    winconfig_event handles tk '<configure>' events. "A Configure event is sent to a window whenever its size, position, or border width changes, and sometimes when it has changed position in the stacking order." IDLE triggers it somehow. It has had intermittent bugs before.

    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/init.py", line 1291, in winfo_width
    self.tk.call('winfo', 'width', self._w))
    _tkinter.TclError: bad window path name ".!listedtoplevel4.!frame.text.!toplevel2"

    The name is for an editor window (listedtoplevel) with a frame with a text with a popup (unlisted toplevel). The toplevel2 suggests that this is the second popup for this text. The name looks correct except that I expected 'text' to maybe be '!text'. In any case, the name is generated by tkinter without IDLE being involved.

    @terryjreedy terryjreedy changed the title IDLE warnings and exceptions IDLE: problem Aug 21, 2020
    @terryjreedy terryjreedy changed the title IDLE warnings and exceptions IDLE: problem Aug 21, 2020
    @terryjreedy
    Copy link
    Member

    Serhiy, should 'text' be '!text' in a tkinter-generated widget name?

    @terryjreedy
    Copy link
    Member

    On my Macbook Air Mohave, I don't get completion boxes on either 3.8.3rc1 or 3.9.0rc1, even when clicking Edit => Show completions. Nor does IDLE quit or print anything in Terminal.

    @terryjreedy terryjreedy changed the title IDLE: problem IDLE: problems with completions on Mac Aug 21, 2020
    @terryjreedy terryjreedy changed the title IDLE: problem IDLE: problems with completions on Mac Aug 21, 2020
    @ronaldoussoren
    Copy link
    Contributor

    It looks like the lack of completions in msg375769 is a problem with Tk 8.6.8 as used by the python.org installers.

    I have a build of master with Tk 8.6.10 on my DTK system and with that Edit->Show completions works in a shell window.

    However: Ctrl+s does not show the completion pop-up, even though the "Edit" button in the application menu flashes (which indicates that Ctrl+s is recognised as a keyboard shortcut). Just using Tab for completion works fine though (shows the completion pop-up).

    ---

    I did get a similar traceback to the one in msg375764 once, this is without using multiprocessing. I haven't been able to reproduce this yet.

    python3.10 -m idlelib  
    Exception in Tkinter callback
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1884, in __call__
        return self.func(*args)
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/idlelib/autocomplete_w.py", line 248, in winconfig_event
        acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1290, in winfo_width
        self.tk.call('winfo', 'width', self._w))
    _tkinter.TclError: bad window path name ".!listedtoplevel.!frame.text.!toplevel8"

    @terryjreedy
    Copy link
    Member

    With 3.10.0b1 on Mac I am getting attribute completion freezes. I had to turn them off. I am tempted to disable completions until there is a Mac IDLE developer to dig into issues like this.

    @taleinat
    Copy link
    Contributor

    With 3.10.0b1 on Mac I am getting attribute completion freezes. I had to turn them off. I am tempted to disable completions until there is a Mac IDLE developer to dig into issues like this.

    Confirmed. This may be a separate issue.

    I have a macOS machine to develop with an will look into this.

    @taleinat
    Copy link
    Contributor

    I can reproduce this consistently on macOS by running IDLE, typing "sys.ba" in the shell and pressing the tab key.

    I've carefully narrowed this down to the call to acw.update() in AutoCompleteWindows.winconfig_event(). Removing that call makes everything work properly.

    That call to acw.update() was added to address the bug reported in bpo-37849 (see PR #59472). That bug was reported on Windows, but apparently doesn't occur on macOS. A quick test on Ubuntu 20.04 with that call removed also appears to not exhibit that bug.

    Therefore, I propose making that call only on Windows.

    Note that there is already another fragile call in the same method that is conditionally called only on Windows, so there is definitely precedent for such a solution.

    @taleinat taleinat added 3.10 only security fixes 3.11 only security fixes type-bug An unexpected behavior, bug, or error labels May 27, 2021
    @taleinat
    Copy link
    Contributor

    I've confirmed that the acw.update() call is still required on Windows to avoid the completion list positioning bug, and that IDLE doesn't freeze as described in this issue on Windows with that call in place.

    @taleinat
    Copy link
    Contributor

    See PR #70588.

    @taleinat
    Copy link
    Contributor

    To clarify, the above is regarding IDLE freezing on macOS after hitting tab to complete, with no completions window open, and with multiple completions possible. That may not be identical to the issue originally reported here. Apologies if I've caused some confusion.

    @taleinat
    Copy link
    Contributor

    New changeset abc4bd5 by Tal Einat in branch 'main':
    bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
    abc4bd5

    @miss-islington
    Copy link
    Contributor

    New changeset 5e6219b by Miss Islington (bot) in branch '3.10':
    bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
    5e6219b

    @miss-islington
    Copy link
    Contributor

    New changeset 65fb9a2 by Miss Islington (bot) in branch '3.9':
    bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
    65fb9a2

    @taleinat
    Copy link
    Contributor

    See a second PR for the originally reported bug, #70592.

    @terryjreedy
    Copy link
    Member

    The completion freeze fix is easily backported to non-Windows installations.

    1. Run IDLE
    2. File => Open Module, enter 'idlelib.autocomplete_w', OK.
    3. Goto line 247 (3.9) or 250 (3.10) with "acw.update".
    4. Add # in from of above to disable it.
    5. Save and close IDLE, then restart.

    For me, with 3.10.0b1, this restores full functions, with boxes appearing as appropriate. With 3.9.5, no freeze by also no box. 2 or 3 tabs brings up first match. 'pr<tab><tab><tab>' = print, 'int.<tab><tab>' = int.as_integer_ratio. As far as I know, the file is the same in both versions. Both versions are the same in Shell and Editor, so it is not the improved 3.10 shell.

    @taleinat
    Copy link
    Contributor

    New changeset 4e2e5c1 by Tal Einat in branch 'main':
    bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
    4e2e5c1

    @taleinat
    Copy link
    Contributor

    New changeset 448abe8 by Miss Islington (bot) in branch '3.10':
    bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
    448abe8

    @taleinat
    Copy link
    Contributor

    New changeset 21a56a4 by Miss Islington (bot) in branch '3.9':
    bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
    21a56a4

    @taleinat
    Copy link
    Contributor

    Both the original bug reported here, and the bug whereby completion could cause IDLE to freeze on macOS, have been fixed and backported to 3.10 and 3.9.

    @terryjreedy
    Copy link
    Member

    bpo-40128, which inserted update_idletasks in a different place, fixed completions for me in installed 3.9.5. They already worked fine for me in installed 3.10.0b2.

    bpo-41859 is another report by Raymond of a 'random' ValueError connected with completions. Closed as a duplicate of this.

    I opened bpo-44398 about 'cntl+space' being changed to the currently non-functional '^S' as the shortcut for Show completions on the macOS Edit menu. ^space does work. Nearly the same issue as cntl+backslash for Show calltip be displayed as the non-functional ^B.

    @terryjreedy terryjreedy reopened this Jun 12, 2021
    @terryjreedy terryjreedy removed the type-bug An unexpected behavior, bug, or error label Jun 12, 2021
    @terryjreedy terryjreedy reopened this Jun 12, 2021
    @terryjreedy terryjreedy removed the type-bug An unexpected behavior, bug, or error label Jun 12, 2021
    @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.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-mac topic-IDLE
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants