8000 gh-103532: Remove TKINTER_PROTECT_LOADTK code (GH-103535) · python/cpython@69e2c42 · GitHub
[go: up one dir, main page]

Skip to content

Commit 69e2c42

Browse files
authored
gh-103532: Remove TKINTER_PROTECT_LOADTK code (GH-103535)
This was only needed for Tk 8.4.13 and older, but Tkinter already requires at least 8.5.12.
1 parent be8903e commit 69e2c42

File tree

3 files changed

+0
-79
lines changed

3 files changed

+0
-79
lines changed

Modules/_tkinter.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,6 @@ static int quitMainLoop = 0;
324324
static int errorInCmd = 0;
325325
static PyObject *excInCmd;
326326

327-
#ifdef TKINTER_PROTECT_LOADTK
328-
static int tk_load_failed = 0;
329-
#endif
330-
331327

332328
static PyObject *Tkapp_UnicodeResult(TkappObject *);
333329

@@ -532,17 +528,7 @@ Tcl_AppInit(Tcl_Interp *interp)
532528
return TCL_OK;
533529
}
534530

535-
#ifdef TKINTER_PROTECT_LOADTK
536-
if (tk_load_failed) {
537-
PySys_WriteStderr("Tk_Init error: %s\n", TKINTER_LOADTK_ERRMSG);
538-
return TCL_ERROR;
539-
}
540-
#endif
541-
542531
if (Tk_Init(interp) == TCL_ERROR) {
543-
#ifdef TKINTER_PROTECT_LOADTK
544-
tk_load_failed = 1;
545-
#endif
546532
PySys_WriteStderr("Tk_Init error: %s\n", Tcl_GetStringResult(interp));
547533
return TCL_ERROR;
548534
}
@@ -635,12 +621,6 @@ Tkapp_New(const char *screenName, const char *className,
635621
Tcl_SetVar(v->interp,
636622
"_tkinter_skip_tk_init", "1", TCL_GLOBAL_ONLY);
637623
}
638-
#ifdef TKINTER_PROTECT_LOADTK
639-
else if (tk_load_failed) {
640-
Tcl_SetVar(v->interp,
641-
"_tkinter_tk_failed", "1", TCL_GLOBAL_ONLY);
642-
}
643-
#endif
644624

645625
/* some initial arguments need to be in argv */
646626
if (sync || use) {
@@ -702,18 +682,6 @@ Tkapp_New(const char *screenName, const char *className,
702682

703683
if (Tcl_AppInit(v->interp) != TCL_OK) {
704684
PyObject *result = Tkinter_Error(v);
705-
#ifdef TKINTER_PROTECT_LOADTK
706-
if (wantTk) {
707-
const char *_tkinter_tk_failed;
708-
_tkinter_tk_failed = Tcl_GetVar(v->interp,
709-
"_tkinter_tk_failed", TCL_GLOBAL_ONLY);
710-
711-
if ( _tkinter_tk_failed != NULL &&
712-
strcmp(_tkinter_tk_failed, "1") == 0) {
713-
tk_load_failed = 1;
714-
}
715-
}
716-
#endif
717685
Py_DECREF((PyObject *)v);
718686
return (TkappObject *)result;
719687
}
@@ -2780,18 +2748,6 @@ _tkinter_tkapp_loadtk_impl(TkappObject *self)
27802748
const char * _tk_exists = NULL;
27812749
int err;
27822750

2783-
#ifdef TKINTER_PROTECT_LOADTK
2784-
/* Up to Tk 8.4.13, Tk_Init deadlocks on the second call when the
2785-
* first call failed.
2786-
* To avoid the deadlock, we just refuse the second call through
2787-
* a static variable.
2788-
*/
2789-
if (tk_load_failed) {
2790-
PyErr_SetString(Tkinter_TclError, TKINTER_LOADTK_ERRMSG);
2791-
return NULL;
2792-
}
2793-
#endif
2794-
27952751
/* We want to guard against calling Tk_Init() multiple times */
27962752
CHECK_TCL_APPARTMENT;
27972753
ENTER_TCL
@@ -2811,9 +2767,6 @@ _tkinter_tkapp_loadtk_impl(TkappObject *self)
28112767
if (_tk_exists == NULL || strcmp(_tk_exists, "1") != 0) {
28122768
if (Tk_Init(interp) == TCL_ERROR) {
28132769
Tkinter_Error(self);
2814-
#ifdef TKINTER_PROTECT_LOADTK
2815-
tk_load_failed = 1;
2816-
#endif
28172770
return NULL;
28182771
}
28192772
}

Modules/tkappinit.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,10 @@
1818

1919
#include "tkinter.h"
2020

21-
#ifdef TKINTER_PROTECT_LOADTK
22-
/* See Tkapp_TkInit in _tkinter.c for the usage of tk_load_faile */
23-
static int tk_load_failed;
24-
#endif
25-
2621
int
2722
Tcl_AppInit(Tcl_Interp *interp)
2823
{
2924
const char *_tkinter_skip_tk_init;
30-
#ifdef TKINTER_PROTECT_LOADTK
31-
const char *_tkinter_tk_failed;
32-
#endif
3325

3426
#ifdef TK_AQUA
3527
#ifndef MAX_PATH_LEN
@@ -90,23 +82,7 @@ Tcl_AppInit(Tcl_Interp *interp)
9082
return TCL_OK;
9183
}
9284

93-
#ifdef TKINTER_PROTECT_LOADTK
94-
_tkinter_tk_failed = Tcl_GetVar(interp,
95-
"_tkinter_tk_failed", TCL_GLOBAL_ONLY);
96-
97-
if (tk_load_failed || (
98-
_tkinter_tk_failed != NULL &&
99-
strcmp(_tkinter_tk_failed, "1") == 0)) {
100-
Tcl_SetResult(interp, TKINTER_LOADTK_ERRMSG, TCL_STATIC);
101-
return TCL_ERROR;
102-
}
103-
#endif
104-
10585
if (Tk_Init(interp) == TCL_ERROR) {
106-
#ifdef TKINTER_PROTECT_LOADTK
107-
tk_load_failed = 1;
108-
Tcl_SetVar(interp, "_tkinter_tk_failed", "1", TCL_GLOBAL_ONLY);
109-
#endif
11086
return TCL_ERROR;
11187
}
11288

Modules/tkinter.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@
1616
(TK_RELEASE_LEVEL << 8) | \
1717
(TK_RELEASE_SERIAL << 0))
1818

19-
/* Protect Tk 8.4.13 and older from a deadlock that happens when trying
20-
* to load tk after a failed attempt. */
21-
#if TK_HEX_VERSION < 0x0804020e
22-
#define TKINTER_PROTECT_LOADTK
23-
#define TKINTER_LOADTK_ERRMSG \
24-
"Calling Tk_Init again after a previous call failed might deadlock"
25-
#endif
26-
2719
#endif /* !TKINTER_H */

0 commit comments

Comments
 (0)
0