GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tkinter.simpledialog: KeyError when a dialog is opened while a window not created by tkinter holds the grab · Issue #157676 · python/cpython

tkinter.simpledialog: KeyError when a dialog is opened while a window not created by tkinter holds the grab #157676

New issue
Copy link
New issue
Copy link
Closed
Closed
tkinter.simpledialog: KeyError when a dialog is opened while a window not created by tkinter holds the grab#157676
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@serhiy-storchaka
serhiy-storchaka
opened on Sep 17, 2026
Issue body actions

Bug report

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.

import tkinter
from tkinter import messagebox, simpledialog
root = tkinter.Tk()
root.after(300, lambda: simpledialog.SimpleDialog(root, text='hi', buttons=['OK']).go())
messagebox.showinfo('t', 'm', parent=root)
KeyError: '__tk__messagebox'

This happens in IDLE when a dialog is opened from an event delivered while a message box is shown (#153481). Regression from #151848 (3.16).

Linked PRs

  • gh-157676: Fix KeyError in tkinter.simpledialog when a foreign window holds the grab #157677

Activity

  1. serhiy-storchaka
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-tkinter
    on Sep 17, 2026
  2. aisk
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 17, 2026
  3. serhiy-storchaka
    added a commit that references this issue on Sep 29, 2026

    gh-157676: Fix KeyError in tkinter.simpledialog when a foreign window…

    3736342
  4. serhiy-storchaka
    closed this as completedon Sep 29, 2026
  5. terryjreedy commented on Sep 29, 2026

    @terryjreedy
    terryjreedy
    on Sep 29, 2026
    Member
    More actions

    OK, no backport because the regression is from the 3.16-only SimpleDialog update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.