diff --git a/Lib/idlelib/autocomplete_w.py b/Lib/idlelib/autocomplete_w.py index 13ff60ae4493e6..50606ed3711aea 100644 --- a/Lib/idlelib/autocomplete_w.py +++ b/Lib/idlelib/autocomplete_w.py @@ -24,6 +24,8 @@ WINCONFIG_SEQUENCE = "" DOUBLECLICK_SEQUENCE = "" +_TK_FULL_VERSION = None + class AutoCompleteWindow: def __init__(self, widget, tags): @@ -61,6 +63,14 @@ def __init__(self, widget, tags): # Flag set to avoid recursive callback invocations. self.is_configuring = False + @property + def _tk_full_version(self): + global _TK_FULL_VERSION + if _TK_FULL_VERSION is None: + version_str = self.widget.tk.call("info", "patchlevel") + _TK_FULL_VERSION = tuple(map(int, version_str.split("."))) + return _TK_FULL_VERSION + def _change_start(self, newstart): min_len = min(len(self.start), len(newstart)) i = 0 @@ -206,7 +216,11 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin): scrollbar.config(command=listbox.yview) scrollbar.pack(side=RIGHT, fill=Y) listbox.pack(side=LEFT, fill=BOTH, expand=True) - acw.update_idletasks() # Need for tk8.6.8 on macOS: #40128. + if ( + platform.system() == "Darwin" and + (8, 6, 8) <= self._tk_full_version < (8, 6, 10) + ): + acw.update_idletasks() # Need for tk8.6.8 on macOS: #40128. acw.lift() # work around bug in Tk 8.5.18+ (issue #24570) # Initialize the listbox selection