Skip to content

gh-140494: Remove dead code ifndef TCL_THREADS, which is always defined#152841

Open
mdehoon wants to merge 1 commit into
python:mainfrom
mdehoon:tkinter_remove_dead_code
Open

gh-140494: Remove dead code ifndef TCL_THREADS, which is always defined#152841
mdehoon wants to merge 1 commit into
python:mainfrom
mdehoon:tkinter_remove_dead_code

Conversation

@mdehoon

@mdehoon mdehoon commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Modules/_tkinter.c always defines TCL_THREADS:

/* If Tcl is compiled for threads, we must also define TCL_THREAD. We define
   it always; if Tcl is not threaded, the thread functions in
   Tcl are empty.  */ 
#define TCL_THREADS

But in two places in Modules/_tkinter.c, we check if TCL_THREADS is defined.

#ifdef TCL_THREADS
static Tcl_ThreadDataKey state_key;
typedef PyThreadState *ThreadSpecificData;
#define tcl_tstate \
    (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*)))
#else
static PyThreadState *tcl_tstate = NULL;
#endif

and

#ifndef TCL_THREADS
    if (v->threaded) {
        PyErr_SetString(PyExc_RuntimeError,
                        "Tcl is threaded but _tkinter is not");
        Py_DECREF(v);
        return 0;
    }
#endif

This PR is a minimal patch that removes the dead code, updates one comment, and fixes one typo in a comment.

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.

1 participant