Skip to content

gh-140494: require that Tcl is built with thread support#141241

Open
mdehoon wants to merge 8 commits into
python:mainfrom
mdehoon:tkinter_threads
Open

gh-140494: require that Tcl is built with thread support#141241
mdehoon wants to merge 8 commits into
python:mainfrom
mdehoon:tkinter_threads

Conversation

@mdehoon

@mdehoon mdehoon commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

This PR modifies _tkinter.c to require that Tcl is built with thread support. It also modifies the documentation file Doc/library/tkinter.rst accordingly.

Note that this only affects Tcl 8.x, as Tcl 9.x no longer has the --disable-threads build option and is always thread-enabled.


📚 Documentation preview 📚: https://cpython-previews--141241.org.readthedocs.build/

@mdehoon

mdehoon commented Nov 8, 2025

Copy link
Copy Markdown
Contributor Author

Note: The compile-time test for TCL_MAJOR_VERSION < 9 is needed because the macOS tests use Tcl from homebrew, which provides Tcl 9.0.2.

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 1, 2026
Comment thread Modules/_tkinter.c Outdated
{
Tcl_Interp* interp;
Tcl_Obj* threaded;
interp = Tcl_CreateInterp();

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.

Is it fine to create an interpreter at import time? The application may have nothing to do with Tcl, just importing tkinter for introspection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The alternative is to have the check in Tkapp_New (and potentially any other Tcl functions that get added to _tkinter in the future).
I understand your concern, but with the check at import time, we are sure that the check is performed, and that it is run only once.

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.

It is fine to check in Tkapp_New. Any other function will likely require an interpreter created in Tkapp_New, or threading will not matter for them. And in the future non-threaded Tcl/Tk will be in the past.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. I have modified the PR and moved the check to Tkapp_New.

@read-the-docs-community

read-the-docs-community Bot commented Jul 18, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33643094 | 📁 Comparing 84f5c28 against main (16d0c89)

  🔍 Preview build  

2 files changed
± library/tkinter.html
± whatsnew/changelog.html

@serhiy-storchaka

Copy link
Copy Markdown
Member

Please refrain from frequent pushes. Only push when you are ready, preferably in a single commit.

@mdehoon

mdehoon commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Please refrain from frequent pushes. Only push when you are ready, preferably in a single commit.

My apologies, my local repository somehow got out of sync with the remote one.
It's done now.

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

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants