Skip to content

gh-156896: Stop scrubbing tkinker submodules upon idlelib.run import - #156915

Merged
terryjreedy merged 1 commit into
python:mainfrom
terryjreedy:run_import
Sep 4, 2026
Merged

gh-156896: Stop scrubbing tkinker submodules upon idlelib.run import#156915
terryjreedy merged 1 commit into
python:mainfrom
terryjreedy:run_import

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Sep 4, 2026

Copy link
Copy Markdown
Member

Instead, invoke the scrubbing within run.main, which is called after the import when starting the IDLE user process.

To manually test that scrub_tkinter_submodules is called when proper, start (or restart) Shell, enter `import tkinter; dir(tkinter), and check that that font, messagebox, ttk, and the dialog modules are missing.

It is obvious from the code that the function is not otherwise called. To test anyway, continue with import tkinter.ttk; import idlelib.run; tkinter.ttk and check for proper output.

…mport

Instead, invoke the scrubbing within run.main, which is called after
the import when starting the IDLE user process.

To manually test that scrub_tkinter_submodules
is called when proper, start (or restart) Shell, enter
`import tkinter; dir(tkinter), and check that that font,
messagebox, ttk, and the dialog modules are missing.

It is obvious from the code that the function is not otherwise
called.  To test anyway, continue with `import tkinter.ttk;
import idlelib.run; tkinter.ttk` and check for proper output.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

I tried more radical approach -- removing any Tkinter dependency from idlelib.run. But this is complicated due to stackviewer.

@terryjreedy

Copy link
Copy Markdown
Member Author

I hope to further reduce the dependency by further reducing the imports. This is part of the purpose of the util module.

@terryjreedy
terryjreedy merged commit e50d233 into python:main Sep 4, 2026
65 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @terryjreedy for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @terryjreedy, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e50d23389be07bf702bde74c3cda794c6febb53e 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @terryjreedy, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e50d23389be07bf702bde74c3cda794c6febb53e 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @terryjreedy, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e50d23389be07bf702bde74c3cda794c6febb53e 3.13

@terryjreedy

terryjreedy commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

The gh-59396 additions in lines 34 to 44 (prior to this patch) were not backported. I will do that later and these backports should then work.

@terryjreedy
terryjreedy deleted the run_import branch September 4, 2026 11:27
@terryjreedy

Copy link
Copy Markdown
Member Author

Serhiy, the not-backported changes are your. See dicord DM.

@bedevere-app

bedevere-app Bot commented Sep 4, 2026

Copy link
Copy Markdown

GH-156958 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 4, 2026
@bedevere-app

bedevere-app Bot commented Sep 4, 2026

Copy link
Copy Markdown

GH-156959 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 4, 2026
@bedevere-app

bedevere-app Bot commented Sep 4, 2026

Copy link
Copy Markdown

GH-156960 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 4, 2026
terryjreedy added a commit that referenced this pull request Sep 4, 2026
…import (GH-156915) (#156959)

gh-156896: Stop scrubbing tkinter submodules upon idlelib.run import (#156915)

Instead, invoke the scrubbing within run.main, which is called after
the import when starting the IDLE user process.

To manually test that scrub_tkinter_submodules
is called when proper, start (or restart) Shell, enter
`import tkinter; dir(tkinter), and check that that font,
messagebox, ttk, and the dialog modules are missing.

It is obvious from the code that the function is not otherwise
called.  To test anyway, continue with `import tkinter.ttk;
import idlelib.run; tkinter.ttk` and check for proper output.

(cherry picked from commit e50d233)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
terryjreedy added a commit that referenced this pull request Sep 4, 2026
…import (GH-156915) (#156960)

gh-156896: Stop scrubbing tkinter submodules upon idlelib.run import (#156915)

Instead, invoke the scrubbing within run.main, which is called after
the import when starting the IDLE user process.

To manually test that scrub_tkinter_submodules
is called when proper, start (or restart) Shell, enter
`import tkinter; dir(tkinter), and check that that font,
messagebox, ttk, and the dialog modules are missing.

It is obvious from the code that the function is not otherwise
called.  To test anyway, continue with `import tkinter.ttk;
import idlelib.run; tkinter.ttk` and check for proper output.

(cherry picked from commit e50d233)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@python python deleted a comment from bedevere-bot Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants