classification
Title: IDLE: problems with completions on Mac
Type: Stage: resolved
Components: IDLE, macOS Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: miss-islington, ned.deily, rhettinger, ronaldoussoren, serhiy.storchaka, taleinat, terry.reedy, vstinner
Priority: normal Keywords: patch

Created on 2020-08-21 17:51 by rhettinger, last changed 2021-06-12 04:48 by terry.reedy. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26400 merged taleinat, 2021-05-27 10:15
PR 26401 merged miss-islington, 2021-05-27 14:30
PR 26402 merged miss-islington, 2021-05-27 14:30
PR 26404 merged taleinat, 2021-05-27 15:29
PR 26419 merged miss-islington, 2021-05-28 06:07
PR 26420 merged miss-islington, 2021-05-28 06:07
Messages (21)
msg375764 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-08-21 17:51
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.
msg375767 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-21 21:30
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.
msg375768 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-21 21:31
Serhiy, should 'text' be '!text' in a tkinter-generated widget name?
msg375769 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-21 21:34
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.
msg380925 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-11-13 19:09
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"
msg394508 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-05-27 02:06
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.
msg394523 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 09:13
> 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.
msg394527 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 10:02
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 GH-15267).  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.
msg394528 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 10:08
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.
msg394530 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 10:16
See PR GH-26400.
msg394531 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 10:17
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.
msg394543 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 14:30
New changeset abc4bd5db91c86b6b74289241378a13bd3a0a5e2 by Tal Einat in branch 'main':
bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
https://github.com/python/cpython/commit/abc4bd5db91c86b6b74289241378a13bd3a0a5e2
msg394544 - (view) Author: miss-islington (miss-islington) Date: 2021-05-27 14:53
New changeset 5e6219b8fa14bc36d1a98dc03b4e01756829fffa by Miss Islington (bot) in branch '3.10':
bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
https://github.com/python/cpython/commit/5e6219b8fa14bc36d1a98dc03b4e01756829fffa
msg394546 - (view) Author: miss-islington (miss-islington) Date: 2021-05-27 15:08
New changeset 65fb9a2701df276852720618bdc2a4bf6adbf810 by Miss Islington (bot) in branch '3.9':
bpo-41611: IDLE: fix freezing on completion on macOS (GH-26400)
https://github.com/python/cpython/commit/65fb9a2701df276852720618bdc2a4bf6adbf810
msg394587 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-27 18:57
See a second PR for the originally reported bug, GH-26404.
msg394591 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-05-27 20:11
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.
msg394634 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-28 06:07
New changeset 4e2e5c1c4f792b4011e4c78d011baea2aee39f1b by Tal Einat in branch 'main':
bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
https://github.com/python/cpython/commit/4e2e5c1c4f792b4011e4c78d011baea2aee39f1b
msg394635 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-28 06:39
New changeset 448abe8d8bcfdf50a5ecae1196199da46bdfed04 by Miss Islington (bot) in branch '3.10':
bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
https://github.com/python/cpython/commit/448abe8d8bcfdf50a5ecae1196199da46bdfed04
msg394636 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-28 06:40
New changeset 21a56a4bce186cd19a50502d2de5117551616005 by Miss Islington (bot) in branch '3.9':
bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() (GH-26404)
https://github.com/python/cpython/commit/21a56a4bce186cd19a50502d2de5117551616005
msg394637 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-28 06:42
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.
msg395676 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-12 04:48
#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.

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

I opened #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.
History
Date User Action Args
2021-06-12 04:48:58terry.reedysetstatus: open -> closed
resolution: fixed
stage: resolved
2021-06-12 04:48:36terry.reedysetstatus: closed -> open
type: behavior ->
messages: + msg395676

resolution: fixed -> (no value)
stage: resolved -> (no value)
2021-06-02 17:36:10terry.reedysetpull_requests: - pull_request25083
2021-06-02 14:29:29vstinnersetnosy: + vstinner

pull_requests: + pull_request25083
2021-05-28 06:42:26taleinatsetstatus: open -> closed
resolution: fixed
messages: + msg394637

stage: patch review -> resolved
2021-05-28 06:40:02taleinatsetmessages: + msg394636
2021-05-28 06:39:44taleinatsetmessages: + msg394635
2021-05-28 06:07:34miss-islingtonsetpull_requests: + pull_request25015
2021-05-28 06:07:29miss-islingtonsetpull_requests: + pull_request25014
2021-05-28 06:07:28taleinatsetmessages: + msg394634
2021-05-27 20:11:02terry.reedysetmessages: + msg394591
2021-05-27 18:57:33taleinatsetmessages: + msg394587
2021-05-27 15:29:45taleinatsetpull_requests: + pull_request24997
2021-05-27 15:08:10miss-islingtonsetmessages: + msg394546
2021-05-27 14:53:58miss-islingtonsetmessages: + msg394544
2021-05-27 14:30:14miss-islingtonsetpull_requests: + pull_request24995
2021-05-27 14:30:07miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request24994
stage: needs patch -> patch review
2021-05-27 14:30:05taleinatsetmessages: + msg394543
2021-05-27 10:17:39taleinatsetmessages: + msg394531
2021-05-27 10:16:04taleinatsetmessages: + msg394530
stage: patch review -> needs patch
2021-05-27 10:15:20taleinatsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request24993
2021-05-27 10:08:55taleinatsetmessages: + msg394528
2021-05-27 10:02:37taleinatsetstage: needs patch
type: behavior
versions: + Python 3.10, Python 3.11
2021-05-27 10:02:07taleinatsetmessages: + msg394527
2021-05-27 09:13:32taleinatsetmessages: + msg394523
2021-05-27 02:06:39terry.reedysetnosy: + taleinat
messages: + msg394508
2021-02-20 06:36:16terry.reedylinkissue41859 superseder
2020-11-13 19:09:03ronaldoussorensetmessages: + msg380925
2020-08-21 21:34:57terry.reedysettitle: IDLE: problem -> IDLE: problems with completions on Mac
2020-08-21 21:34:37terry.reedysetmessages: + msg375769
2020-08-21 21:31:09terry.reedysetmessages: + msg375768
2020-08-21 21:30:16terry.reedysettitle: IDLE warnings and exceptions -> IDLE: problem
nosy: + serhiy.storchaka, ronaldoussoren, ned.deily

messages: + msg375767

components: + macOS
2020-08-21 17:51:37rhettingercreate