Skip to content

IDLE on macOS 27 hangs when a menu command opens a dialog #158053

Closed

Description

Bug report

Bug description:

IDLE on macOS 27 hangs (beach ball, Force Quit) when a menu command opens a dialog or waits on the shell socket. The process is not idle-locked by user code. The main thread is stuck inside the macOS menu-bar callback.

What happens

macOS 27.0 (build 26A428) delivers menu clicks through MenuBarClientCore 1.0 while Tk is already inside its event loop. Tk runs the menu command on that stack. If the command opens a modal dialog, or enters another Tk event loop that blocks in select (IDLE waiting on the Run/Shell subprocess), the menu-bar call never returns. The window stops redrawing. Activity Monitor shows the process as not responding. Force Quit is the only way out. Unsaved editor text is lost.

This did not happen on macOS Tahoe 26.6.2. It started after the update to macOS 27 (this machine: 2026-09-10). The Python.org installers were not changed at that time.

Reproduced with

Official python.org IDLE.app, native arm64, Rosetta not involved.

  • Python 3.14.7, Tk 9.0.4. Hang sample: main thread in MenuBarClientCore â�� Tk â�� nested event loop â�� select / sock_accept.
  • Python 3.13.14, Tk 8.6.18. Same stack from IDLE > Settings (::tk::mac::ShowPreferences). Settings is enough. No user script required.

Reliable steps:

  1. Install the python.org macOS package for 3.13 or 3.14.
  2. Launch IDLE.app.
  3. Click IDLE > Settings in the menu bar.
  4. Beach ball. The Settings window does not finish opening. Force Quit.

Save As and Run Module can take the same path, because they open a dialog or wait on the shell socket before the menu callback returns.

Expected

The menu action returns, then IDLE opens Settings (or the save dialog, or runs the module). The window stays responsive.

Cause

The hang is the nested event loop inside the menu-bar callback, not IDLE's editor code and not the user's program. A menu command that returns immediately, then does the real work on the next Tk turn, does not hang. Verified on both 3.13.14 and 3.14.7: after that deferral, IDLE > Settings opens and the process stays in Tk_mainloop.

Suggested fix

On macOS, IDLE should not run dialog or shell work inside the menu-bar callback. Schedule those commands with after idle (and the same for ::tk::mac::ShowPreferences, ShowHelp, Quit, and the standard About panel) so MenuBarClientCore's call returns before Tk nests another loop.

This should live in idlelib (macosx.py or the menu setup), not as a per-user extension. Other Tk apps on macOS 27 have the same OS interaction; Apple is being asked, separately, to make the menu bar tolerate a nested run loop. IDLE still needs the deferral so current macOS 27 users are not stuck.

Environment

  • macOS 27.0 (26A428), MenuBarClientCore 1.0 (97.0.9.402)
  • Previous OS, where this did not happen: macOS Tahoe 26.6.2
  • CPython 3.13.14 (Tk 8.6) and 3.14.7 (Tk 9.0), both from python.org macOS installers
  • Native arm64

CPython versions tested on:

3.14, 3.13

Operating systems tested on:

macOS

Activity

  1. added
    type-bug
    on Sep 24, 2026
  2. terryjreedy commented on Sep 24, 2026

    @terryjreedy
    Member

    @Universe-Of-The-Creator Thank you for the report. Can you test your proposed fix on one dialog that fail, such as About? Can you apply PRs to test?
    @ronaldoussoren @ned-deily Do either of you know anything about this nasty macOS 27.0 regression? Which of you upgraded so you can test proposed patches?
    @serhiy-storchaka This is not my personal priority, but seems nasty for mac users who install 27.0+. Have any suggestion?

  3. added
    3.13
    3.14
    3.15
    3.16
    on Sep 24, 2026
  4. ned-deily commented on Sep 24, 2026

    @ned-deily
    Member

    Thanks, @Universe-Of-The-Creator, for the report and the detailed description and analysis. The hanging behavior is indeed easily reproducible on macOS 27.0. And, just to be clear, it is not limited to python.org macOS builds running on 27.0.

    @culler, @serhiy-storchaka, any thoughts for a workaround?
    @Universe-Of-The-Creator, confirming that you have opened an issue with Apple?

  5. Universe-Of-The-Creator commented on Sep 24, 2026

    @Universe-Of-The-Creator
    Author

    Tested the workaround on About, with the local wrapper removed first.

    Without the wrapper, IDLE > About IDLE does not open. The process stays inside the menu-bar callback, enters a nested Tk event loop, and blocks in select. Accessibility cannot read the window list. Reproduced on the official python.org IDLE.app, native arm64, macOS 27.0 (26A428):

    • Python 3.13.14 / Tk 8.6.18
    • Python 3.14.7 / Tk 9.0.4

    With the wrapper restored, About opens on both versions. The process stays in the normal Tk main loop. No hang.

    The workaround is still a user extension, not an idlelib patch. The menu command returns immediately, then the real work runs on the next Tk turn (after idle). About, Settings, Help, and Quit are deferred that way.

    Yes. This Mac can test a PR or a small idlelib patch. The local wrapper has to be turned off first, or it will mask the result.

    Apple Feedback Assistant report: FB24915676 (Menu Bar, application unresponsive, sysdiagnose attached). That is the external path into Radar.

  6. serhiy-storchaka commented on Sep 24, 2026

    @serhiy-storchaka
    Member

    This is Tk ticket 33b3af1cea, reported for the macOS 27 beta: a modal dialog opened directly from a menu command hangs, while the same dialog deferred with after idle works. So yes, deferring is the right workaround. The proper fix belongs in Tk (cc @culler), so that it works for all Tk applications, but until then IDLE can defer its menu commands and the ::tk::mac::* handlers (ShowPreferences, ShowHelp, Quit, About) with after_idle() on macOS.

  7. culler commented on Sep 25, 2026

    @culler
    Contributor

    I will look at the Tk fix as soon as I have access to a macOS 27 system, which will be next week.

  8. ned-deily commented on Sep 25, 2026

    @ned-deily
    Member

    FTR, the next releases of Python will be happening later next week. If there are workaround or fix PRs or patches for IDLE, tkinter, and/or Tk 9.0.4 available by Tuesday evening, I will try to get them applied and backported for the releases.

  9. terryjreedy commented on Sep 25, 2026

    @terryjreedy
    Member

    Ned, I believe Serhiy is suggesting for IDLE to replace vulnerable(args) with something like

    if bad_situation:
        w.after_idle(vulnerable, args)
    else:
        vulnerable(args)
    

    where w is any window/widget, as they all get the method.
    The problem I see is that the code that follows the vulnerable call that opens a modal dialog will at least in some cases require that the delayed call be complete. What I would try (from memory) is to save the after id and enter a 1 millisecond after loop checking for the non-existence of the after id with after_info.

  10. 16 remaining items

  11. culler commented on Sep 30, 2026

    @culler
    Contributor

    My thoughts:

    I don't think this will be addressed by a future Apple release. I think that the way that Tk uses the AppKit event loop will be considered to be unorthodox (even though the copyright indicates it was originally written by Apple and by a Tk developer who became an Apple employee). Also I suspect that this breakage was a side effect of a fairly significant redesign of the menubar code. The macOS 27 release includes quite a few changes to the menubar. If Apple responds at all to the radar submission, I would expect the response to be "won't fix" or "not a bug". Plus, I don't think "make the menu bar tolerate a nested run loop" translates into anything that will be meaningful to Apple. RunLoop modes live on a stack. I think that "nested RunLoops", as I understand the term, are common and supported.

    I think a backport of the current workaround to 8.6 would be easy. The Tk code that changed for the workaround is quite old and did not change between 8.6 and 9.1. Also, the tests show no issues for the bugfix branch (But I ran the tests on a "real" computer, and these days all that matters is how the tests behave on a CI runner. I haven't checked that yet.)

    I am not happy with this workaround because I cannot explain why it works. Currently I suspect that the magic actually happens in Tcl which, as I (re)-discovered last night, actually does create and run Apple RunLoops in its Notifier module.

    I hope that Python will move to Tk 9.1 as soon as possible. There are only a very small number of changes to tkinter needed to make all tests pass with 9.1. We are near the end of life for 9.0 and its life was intended to be short. It was just meant to be a transition helper.

  12. ned-deily commented on Oct 3, 2026

    @ned-deily
    Member
  13. culler commented on Oct 5, 2026

    @culler
    Contributor

    I have now merged the suggested idle task fix for this bug into the tips of core-8-6-branch, core-9-0-branch and main (9.1) on the Tk fossil repository and checked that IDLE works with the tip of Tk 9.0, which is 9.0.5. I was able to come up with an explanation for why it works that I found plausible and I convinced myself that this is the most reasonable, if not the only, viable approach.

    I am not sure if people realize how easy it now is (thanks Ned!) to modify macOS python to use a newer version of Tk (at least a new patch release). It is necessary to build and install the desired versions of Tcl and Tk to do that, using the default framework builds via make -C macosx. But once they are installed, all one needs to do is:

    % cd /Library/Frameworks/Python.framework/Versions/3.14/Frameworks
    % mkdir saved
    % mv {Tcl,Tk}.framework saved
    % ln -s /Library/Frameworks/{Tcl,Tk}.framework .
    

    To undo, remove the symlinks and move the saved framework up a level.

  14. Roxy373-ai commented on Oct 13, 2026

    @Roxy373-ai

    I'm considering upgrading an Apple Silicon Mac from macOS 26.5.1 to 27.0.1 and checking Python 3.14 / IDLE compatibility first. I saw the report that 27.0.1 still has this issue, the October 5 update that the Tk fix is merged, and the warning on the Python 3.14.8 release page.

    Is there now a released python.org macOS installer that includes the fixed Tk version, or a planned installer update users should watch for? For users who need IDLE/tkinter and don't want to build Tcl/Tk themselves, is deferring the macOS upgrade still the recommended route?

    I haven't upgraded or reproduced the issue myself; this is a question about the availability of the fix.

  15. ned-deily commented on Oct 15, 2026

    @ned-deily
    Member

    @Roxy373-ai The Tk issue has been re-opened with some additional discussion about how best to fix the problem. It is a tricky thing to get right! So, for the moment, we have held off issuing any python.org macOS installer updates until this is resolved, preferably in an official TK release.

  16. culler commented on Oct 15, 2026

    @culler
    Contributor

    The Tk issue was re-opened because there was a missing Tcl_Preserve/Tcl_Release pair that could possibly cause a crash in the extremely unlikely event that someone managed to open an About panel in an interpreter that had been destroyed. But that pair has already been added and the change committed to the main branch.

  17. ned-deily commented on Oct 21, 2026

    @ned-deily
    Member

    Update: as of 2026-10-21, Python 3.15.1, 3.14.9, and 3.13.17 have been released. The python.org macOS installers provided with those releases include a pre-release build of Tk 9.0.5 (3.15.1 and 3.14.9) or Tk 8.6.19 (3.13.17) that includes the Tk change discussed above.

    As other distributors of Python update their versions of Tk, this problem should no longer be seen with current versions. Keep in mind that, as of now, there is no known workaround for previously released versions of Tk running on macOS 27.

  18. Universe-Of-The-Creator commented on Oct 22, 2026

    @Universe-Of-The-Creator
    Author

    This was awesome watching everyone work together on a solution, especially it being my first bug report

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

    3.133.143.153.16OS-mactopic-tkintertype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions