simpledialog.SimpleDialog.go() and Dialog use _temp_grab_focus(), which calls grab_current() and focus_get() to restore the previous grab and focus afterwards. Both convert the Tcl window name with _nametowidget(), which raises KeyError for windows which were not created by tkinter, such as the native message box (.__tk__messagebox) or Tk's file dialogs on X11.
Activity
gh-157676: Fix KeyError in tkinter.simpledialog when a foreign window…
terryjreedy commented on Sep 29, 2026
OK, no backport because the regression is from the 3.16-only SimpleDialog update.