Sitelet https://github.com/python/cpython/issues/97527
Skip to content

IDLE: protect macOS Tk() call when no GUI #97527

Description

@terryjreedy

The no-gui (mock Text) test_squeezer.SqueezerTest.test_write_stdout indirectly calls squeezer.Squeezer.mywrite, which calls macosx.isAquaTk, which calls _init_tk_type, which calls tkinter.Tk to initialize macosx._tk_type. When a test is run on macOS with no GUI, this crashes; see #97032 for an example.

test_squeezer later calls isAquaTk directly. Even if we fix test_squeezer, there are about 10 other isAquaTk calls in idlelib that someday might be triggered by more complete tests. I will try patching _init_tk_type in branch tktype to skip Tk() when it would crash.

Activity

  1. added 2 commits that reference this issue on Sep 24, 2022
  2. added 4 commits that reference this issue on Sep 24, 2022
  3. terryjreedy commented on Oct 15, 2022

    @terryjreedy
    MemberAuthor

    The fix in #97530 for a testing-only bug, merged after 3.11.rc2, introduced a runtime-only bug of disable IDLE startup when test/* is not installed. This bug was released in 3.12.0a1, 3.10.8, and Microsoft Python 3.10.2288.0. It was reported on SO for the last: https://stackoverflow.com/questions/74070702/python-m-idlelib-idle-not-working-windows-10/74082858#74082858.

    The immediate fix for anyone is to delete the import on line 7 and replace the try suite on line 23 with pass. Windows people who omitted the test suite can Modify and add it.

    @pablogsal I hope you did not cherr-pick the buggy 'fix' into 3.11.0. If you did, I will have a better fix soon.

    @zooba Does MS Python allow installing the test? Once the new fix is merged, could you let the MS Python person know?

    @ned-deily As near as I could tell, one cannot install psf mac python without the tests. Correct? Do you know about homebrew? (And will we ever be rid of some of the mac graphics options?)

    [Longer term, I want to consolidate macosx imports and if possible only do them on mac.]

  4. pablogsal commented on Oct 15, 2022

    @pablogsal
    Member

    All cherry picks will be done hours before the release so we are safe. Just tell me what you want me to add and I will make sure is there the day of the final release .

  5. added a commit that references this issue on Oct 16, 2022
  6. terryjreedy commented on Oct 16, 2022

    @terryjreedy
    MemberAuthor

    #98313 follows on #97530. Reversion or #97530 or merging of #98313 would only be essential if #97530 had already been merged. The net effect of both is to prevent test_idle possibly crashing macOS with no GUI, now or with test revisions. AFAIK, CI and buildbots only run current repository versions, not release versions. So I don't think the release needs any change.

  7. added a commit that references this issue on Oct 16, 2022
  8. added 5 commits that reference this issue on Oct 16, 2022
  9. zooba commented on Oct 17, 2022

    @zooba
    Member

    @terryjreedy No, the Store package doesn't have any way to install the test suite. If we need those helpers, they should be copied elsewhere (either idlelib, tkinter or unittest probably - I'll let you make that call).

    That said, if they're only needed for Mac, then handling the import error should also be fine.

  10. added a commit that references this issue on Oct 17, 2022
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.10 (EOL)end of life3.11only security fixes3.12only security fixestopic-IDLEtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions