Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a66cf5bd
Kaydet (Commit)
a66cf5bd
authored
Şub 09, 2009
tarafından
Guilherme Polo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed issue #5122: Synchronize tk load failure check to prevent a
potential deadlock.
üst
55bdb8e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
30 deletions
+125
-30
NEWS
Misc/NEWS
+3
-0
_tkinter.c
Modules/_tkinter.c
+63
-26
tkappinit.c
Modules/tkappinit.c
+34
-4
tkinter.h
Modules/tkinter.h
+25
-0
No files found.
Misc/NEWS
Dosyayı görüntüle @
a66cf5bd
...
@@ -152,6 +152,9 @@ Core and Builtins
...
@@ -152,6 +152,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #5122: Synchronize tk load failure check to prevent a potential
deadlock.
- Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
- Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
- Issue #5170: Fixed Unicode output bug in logging and added test case.
- Issue #5170: Fixed Unicode output bug in logging and added test case.
...
...
Modules/_tkinter.c
Dosyayı görüntüle @
a66cf5bd
...
@@ -33,6 +33,8 @@ Copyright (C) 1994 Steen Lumholt.
...
@@ -33,6 +33,8 @@ Copyright (C) 1994 Steen Lumholt.
#include <windows.h>
#include <windows.h>
#endif
#endif
#include "tkinter.h"
/* Allow using this code in Python 2.[12] */
/* Allow using this code in Python 2.[12] */
#ifndef PyDoc_STRVAR
#ifndef PyDoc_STRVAR
#define PyDoc_STRVAR(name,str) static char name[] = str
#define PyDoc_STRVAR(name,str) static char name[] = str
...
@@ -74,9 +76,7 @@ Copyright (C) 1994 Steen Lumholt.
...
@@ -74,9 +76,7 @@ Copyright (C) 1994 Steen Lumholt.
#define CONST
#define CONST
#endif
#endif
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
#if TK_VERSION_HEX < 0x08020002
#if TKMAJORMINOR < 8002
#error "Tk older than 8.2 not supported"
#error "Tk older than 8.2 not supported"
#endif
#endif
...
@@ -280,6 +280,9 @@ static PyObject *excInCmd;
...
@@ -280,6 +280,9 @@ static PyObject *excInCmd;
static
PyObject
*
valInCmd
;
static
PyObject
*
valInCmd
;
static
PyObject
*
trbInCmd
;
static
PyObject
*
trbInCmd
;
#ifdef TKINTER_PROTECT_LOADTK
static
int
tk_load_failed
;
#endif
static
PyObject
*
static
PyObject
*
...
@@ -555,21 +558,35 @@ SplitObj(PyObject *arg)
...
@@ -555,21 +558,35 @@ SplitObj(PyObject *arg)
int
int
Tcl_AppInit
(
Tcl_Interp
*
interp
)
Tcl_AppInit
(
Tcl_Interp
*
interp
)
{
{
Tk_Window
main
;
const
char
*
_tkinter_skip_tk_init
;
const
char
*
_tkinter_skip_tk_init
;
if
(
Tcl_Init
(
interp
)
==
TCL_ERROR
)
{
if
(
Tcl_Init
(
interp
)
==
TCL_ERROR
)
{
PySys_WriteStderr
(
"Tcl_Init error: %s
\n
"
,
Tcl_GetStringResult
(
interp
));
PySys_WriteStderr
(
"Tcl_Init error: %s
\n
"
,
Tcl_GetStringResult
(
interp
));
return
TCL_ERROR
;
return
TCL_ERROR
;
}
}
_tkinter_skip_tk_init
=
Tcl_GetVar
(
interp
,
"_tkinter_skip_tk_init"
,
TCL_GLOBAL_ONLY
);
if
(
_tkinter_skip_tk_init
==
NULL
||
strcmp
(
_tkinter_skip_tk_init
,
"1"
)
!=
0
)
{
_tkinter_skip_tk_init
=
Tcl_GetVar
(
interp
,
main
=
Tk_MainWindow
(
interp
);
"_tkinter_skip_tk_init"
,
TCL_GLOBAL_ONLY
);
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
{
if
(
_tkinter_skip_tk_init
!=
NULL
&&
PySys_WriteStderr
(
"Tk_Init error: %s
\n
"
,
Tcl_GetStringResult
(
interp
));
strcmp
(
_tkinter_skip_tk_init
,
"1"
)
==
0
)
{
return
TCL_ERROR
;
return
TCL_OK
;
}
}
#ifdef TKINTER_PROTECT_LOADTK
if
(
tk_load_failed
)
{
PySys_WriteStderr
(
"Tk_Init error: %s
\n
"
,
TKINTER_LOADTK_ERRMSG
);
return
TCL_ERROR
;
}
#endif
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
{
#ifdef TKINTER_PROTECT_LOADTK
tk_load_failed
=
1
;
#endif
PySys_WriteStderr
(
"Tk_Init error: %s
\n
"
,
Tcl_GetStringResult
(
interp
));
return
TCL_ERROR
;
}
}
return
TCL_OK
;
return
TCL_OK
;
}
}
#endif
/* !WITH_APPINIT */
#endif
/* !WITH_APPINIT */
...
@@ -652,8 +669,15 @@ Tkapp_New(char *screenName, char *baseName, char *className,
...
@@ -652,8 +669,15 @@ Tkapp_New(char *screenName, char *baseName, char *className,
ckfree
(
argv0
);
ckfree
(
argv0
);
if
(
!
wantTk
)
{
if
(
!
wantTk
)
{
Tcl_SetVar
(
v
->
interp
,
"_tkinter_skip_tk_init"
,
"1"
,
TCL_GLOBAL_ONLY
);
Tcl_SetVar
(
v
->
interp
,
"_tkinter_skip_tk_init"
,
"1"
,
TCL_GLOBAL_ONLY
);
}
#ifdef TKINTER_PROTECT_LOADTK
else
if
(
tk_load_failed
)
{
Tcl_SetVar
(
v
->
interp
,
"_tkinter_tk_failed"
,
"1"
,
TCL_GLOBAL_ONLY
);
}
}
#endif
/* some initial arguments need to be in argv */
/* some initial arguments need to be in argv */
if
(
sync
||
use
)
{
if
(
sync
||
use
)
{
...
@@ -688,6 +712,18 @@ Tkapp_New(char *screenName, char *baseName, char *className,
...
@@ -688,6 +712,18 @@ Tkapp_New(char *screenName, char *baseName, char *className,
if
(
Tcl_AppInit
(
v
->
interp
)
!=
TCL_OK
)
{
if
(
Tcl_AppInit
(
v
->
interp
)
!=
TCL_OK
)
{
PyObject
*
result
=
Tkinter_Error
((
PyObject
*
)
v
);
PyObject
*
result
=
Tkinter_Error
((
PyObject
*
)
v
);
#ifdef TKINTER_PROTECT_LOADTK
if
(
wantTk
)
{
const
char
*
_tkinter_tk_failed
;
_tkinter_tk_failed
=
Tcl_GetVar
(
v
->
interp
,
"_tkinter_tk_failed"
,
TCL_GLOBAL_ONLY
);
if
(
_tkinter_tk_failed
!=
NULL
&&
strcmp
(
_tkinter_tk_failed
,
"1"
)
==
0
)
{
tk_load_failed
=
1
;
}
}
#endif
Py_DECREF
((
PyObject
*
)
v
);
Py_DECREF
((
PyObject
*
)
v
);
return
(
TkappObject
*
)
result
;
return
(
TkappObject
*
)
result
;
}
}
...
@@ -2669,23 +2705,22 @@ Tkapp_InterpAddr(PyObject *self, PyObject *args)
...
@@ -2669,23 +2705,22 @@ Tkapp_InterpAddr(PyObject *self, PyObject *args)
static
PyObject
*
static
PyObject
*
Tkapp_TkInit
(
PyObject
*
self
,
PyObject
*
args
)
Tkapp_TkInit
(
PyObject
*
self
,
PyObject
*
args
)
{
{
static
int
has_failed
;
Tcl_Interp
*
interp
=
Tkapp_Interp
(
self
);
Tcl_Interp
*
interp
=
Tkapp_Interp
(
self
);
Tk_Window
main_window
;
const
char
*
_tk_exists
=
NULL
;
const
char
*
_tk_exists
=
NULL
;
int
err
;
int
err
;
main_window
=
Tk_MainWindow
(
interp
);
#ifdef TKINTER_PROTECT_LOADTK
/*
In all current versions of Tk (including 8.4.13), Tk_Init
/*
Up to Tk 8.4.13, Tk_Init deadlocks on the second call when the
deadlocks on the second call when the
first call failed.
*
first call failed.
To avoid the deadlock, we just refuse the second call through
*
To avoid the deadlock, we just refuse the second call through
a static variable. */
* a static variable.
if
(
has_failed
)
{
*/
PyErr_SetString
(
Tkinter_TclError
,
if
(
tk_load_failed
)
{
"Calling Tk_Init again after a previous call failed might deadlock"
);
PyErr_SetString
(
Tkinter_TclError
,
TKINTER_LOADTK_ERRMSG
);
return
NULL
;
return
NULL
;
}
}
#endif
/* We want to guard against calling Tk_Init() multiple times */
/* We want to guard against calling Tk_Init() multiple times */
CHECK_TCL_APPARTMENT
;
CHECK_TCL_APPARTMENT
;
ENTER_TCL
ENTER_TCL
...
@@ -2704,8 +2739,10 @@ Tkapp_TkInit(PyObject *self, PyObject *args)
...
@@ -2704,8 +2739,10 @@ Tkapp_TkInit(PyObject *self, PyObject *args)
}
}
if
(
_tk_exists
==
NULL
||
strcmp
(
_tk_exists
,
"1"
)
!=
0
)
{
if
(
_tk_exists
==
NULL
||
strcmp
(
_tk_exists
,
"1"
)
!=
0
)
{
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
{
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
{
PyErr_SetString
(
Tkinter_TclError
,
Tcl_GetStringResult
(
Tkapp_Interp
(
self
)));
PyErr_SetString
(
Tkinter_TclError
,
Tcl_GetStringResult
(
Tkapp_Interp
(
self
)));
has_failed
=
1
;
#ifdef TKINTER_PROTECT_LOADTK
tk_load_failed
=
1
;
#endif
return
NULL
;
return
NULL
;
}
}
}
}
...
...
Modules/tkappinit.c
Dosyayı görüntüle @
a66cf5bd
...
@@ -16,11 +16,21 @@
...
@@ -16,11 +16,21 @@
#include <tcl.h>
#include <tcl.h>
#include <tk.h>
#include <tk.h>
#include "tkinter.h"
#ifdef TKINTER_PROTECT_LOADTK
/* See Tkapp_TkInit in _tkinter.c for the usage of tk_load_faile */
static
int
tk_load_failed
;
#endif
int
int
Tcl_AppInit
(
Tcl_Interp
*
interp
)
Tcl_AppInit
(
Tcl_Interp
*
interp
)
{
{
Tk_Window
main_window
;
Tk_Window
main_window
;
const
char
*
_tkinter_skip_tk_init
;
const
char
*
_tkinter_skip_tk_init
;
#ifdef TKINTER_PROTECT_LOADTK
const
char
*
_tkinter_tk_failed
;
#endif
#ifdef TK_AQUA
#ifdef TK_AQUA
#ifndef MAX_PATH_LEN
#ifndef MAX_PATH_LEN
...
@@ -74,12 +84,32 @@ Tcl_AppInit(Tcl_Interp *interp)
...
@@ -74,12 +84,32 @@ Tcl_AppInit(Tcl_Interp *interp)
/* Initialize modules that don't require Tk */
/* Initialize modules that don't require Tk */
#endif
#endif
_tkinter_skip_tk_init
=
Tcl_GetVar
(
interp
,
"_tkinter_skip_tk_init"
,
TCL_GLOBAL_ONLY
);
_tkinter_skip_tk_init
=
Tcl_GetVar
(
interp
,
if
(
_tkinter_skip_tk_init
!=
NULL
&&
strcmp
(
_tkinter_skip_tk_init
,
"1"
)
==
0
)
{
"_tkinter_skip_tk_init"
,
TCL_GLOBAL_ONLY
);
if
(
_tkinter_skip_tk_init
!=
NULL
&&
strcmp
(
_tkinter_skip_tk_init
,
"1"
)
==
0
)
{
return
TCL_OK
;
return
TCL_OK
;
}
}
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
#ifdef TKINTER_PROTECT_LOADTK
_tkinter_tk_failed
=
Tcl_GetVar
(
interp
,
"_tkinter_tk_failed"
,
TCL_GLOBAL_ONLY
);
if
(
tk_load_failed
||
(
_tkinter_tk_failed
!=
NULL
&&
strcmp
(
_tkinter_tk_failed
,
"1"
)
==
0
))
{
Tcl_SetResult
(
interp
,
TKINTER_LOADTK_ERRMSG
,
TCL_STATIC
);
return
TCL_ERROR
;
}
#endif
if
(
Tk_Init
(
interp
)
==
TCL_ERROR
)
{
#ifdef TKINTER_PROTECT_LOADTK
tk_load_failed
=
1
;
Tcl_SetVar
(
interp
,
"_tkinter_tk_failed"
,
"1"
,
TCL_GLOBAL_ONLY
);
#endif
return
TCL_ERROR
;
return
TCL_ERROR
;
}
main_window
=
Tk_MainWindow
(
interp
);
main_window
=
Tk_MainWindow
(
interp
);
...
...
Modules/tkinter.h
0 → 100644
Dosyayı görüntüle @
a66cf5bd
#ifndef TKINTER_H
#define TKINTER_H
/* This header is used to share some macros between _tkinter.c and
* tkappinit.c */
/* TK_RELEASE_LEVEL is always one of the following:
* TCL_ALPHA_RELEASE 0
* TCL_BETA_RELEASE 1
* TCL_FINAL_RELEASE 2
*/
#define TK_VERSION_HEX ((TK_MAJOR_VERSION << 24) | \
(TK_MINOR_VERSION << 16) | \
(TK_RELEASE_SERIAL << 8) | \
(TK_RELEASE_LEVEL << 0))
/* Protect Tk 8.4.13 and older from a deadlock that happens when trying
* to load tk after a failed attempt. */
#if TK_VERSION_HEX < 0x08040e02
#define TKINTER_PROTECT_LOADTK
#define TKINTER_LOADTK_ERRMSG \
"Calling Tk_Init again after a previous call failed might deadlock"
#endif
#endif
/* !TKINTER_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment