|
| 1 | +diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py |
| 2 | +index bfec04bb6c1..6f3cfba6bbf 100644 |
| 3 | +--- a/Lib/tkinter/__init__.py |
| 4 | ++++ b/Lib/tkinter/__init__.py |
| 5 | +@@ -54,6 +54,12 @@ |
| 6 | + _magic_re = re.compile(r'([\\{}])') |
| 7 | + _space_re = re.compile(r'([\s])', re.ASCII) |
| 8 | + |
| 9 | ++# Facilitate discovery of the Tcl/Tk libraries. |
| 10 | ++import os |
| 11 | ++ |
| 12 | ++os.environ['TCL_LIBRARY'] = sys.base_prefix + '/tcl/tcl' + _tkinter.TCL_VERSION |
| 13 | ++os.environ['TK_LIBRARY'] = sys.base_prefix + '/tcl/tk' + _tkinter.TK_VERSION |
| 14 | ++ |
| 15 | + |
| 16 | + def _join(value): |
| 17 | + """Internal function.""" |
| 18 | +diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c |
| 19 | +index 45897817a56..03652c86c1b 100644 |
| 20 | +--- a/Modules/_tkinter.c |
| 21 | ++++ b/Modules/_tkinter.c |
| 22 | +@@ -26,9 +26,8 @@ Copyright (C) 1994 Steen Lumholt. |
| 23 | + #endif |
| 24 | + |
| 25 | + #include "Python.h" |
| 26 | +-#ifdef MS_WINDOWS |
| 27 | +-# include "pycore_fileutils.h" // _Py_stat() |
| 28 | +-#endif |
| 29 | ++ |
| 30 | ++#include "pycore_fileutils.h" // _Py_stat() |
| 31 | + |
| 32 | + #include "pycore_long.h" // _PyLong_IsNegative() |
| 33 | + |
| 34 | +@@ -132,6 +131,7 @@ typedef int Tcl_Size; |
| 35 | + #ifdef MS_WINDOWS |
| 36 | + #include <conio.h> |
| 37 | + #define WAIT_FOR_STDIN |
| 38 | ++#endif |
| 39 | + |
| 40 | + static PyObject * |
| 41 | + _get_tcl_lib_path(void) |
| 42 | +@@ -149,7 +149,7 @@ _get_tcl_lib_path(void) |
| 43 | + } |
| 44 | + |
| 45 | + /* Check expected location for an installed Python first */ |
| 46 | +- tcl_library_path = PyUnicode_FromString("\\tcl\\tcl" TCL_VERSION); |
| 47 | ++ tcl_library_path = PyUnicode_FromString("/tcl/tcl" TCL_VERSION); |
| 48 | + if (tcl_library_path == NULL) { |
| 49 | + return NULL; |
| 50 | + } |
| 51 | +@@ -167,7 +167,7 @@ _get_tcl_lib_path(void) |
| 52 | + errno = 0; |
| 53 | + #ifdef Py_TCLTK_DIR |
| 54 | + tcl_library_path = PyUnicode_FromString( |
| 55 | +- Py_TCLTK_DIR "\\lib\\tcl" TCL_VERSION); |
| 56 | ++ Py_TCLTK_DIR "/lib/tcl" TCL_VERSION); |
| 57 | + if (tcl_library_path == NULL) { |
| 58 | + return NULL; |
| 59 | + } |
| 60 | +@@ -189,7 +189,6 @@ _get_tcl_lib_path(void) |
| 61 | + } |
| 62 | + return tcl_library_path; |
| 63 | + } |
| 64 | +-#endif /* MS_WINDOWS */ |
| 65 | + |
| 66 | + /* The threading situation is complicated. Tcl is not thread-safe, except |
| 67 | + when configured with --enable-threads. |
| 68 | +@@ -702,7 +701,6 @@ Tkapp_New(const char *screenName, const char *className, |
| 69 | + PyMem_Free(args); |
| 70 | + } |
| 71 | + |
| 72 | +-#ifdef MS_WINDOWS |
| 73 | + { |
| 74 | + PyObject *str_path; |
| 75 | + PyObject *utf8_path; |
| 76 | +@@ -727,7 +725,6 @@ Tkapp_New(const char *screenName, const char *className, |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | +-#endif |
| 81 | + |
| 82 | + if (Tcl_AppInit(v->interp) != TCL_OK) { |
| 83 | + PyObject *result = Tkinter_Error(v); |
| 84 | +@@ -3520,7 +3517,6 @@ PyInit__tkinter(void) |
| 85 | + if (uexe && PyUnicode_Check(uexe)) { // sys.executable can be None |
| 86 | + cexe = PyUnicode_EncodeFSDefault(uexe); |
| 87 | + if (cexe) { |
| 88 | +-#ifdef MS_WINDOWS |
| 89 | + int set_var = 0; |
| 90 | + PyObject *str_path; |
| 91 | + wchar_t *wcs_path; |
| 92 | +@@ -3551,9 +3547,6 @@ PyInit__tkinter(void) |
| 93 | + SetEnvironmentVariableW(L"TCL_LIBRARY", NULL); |
| 94 | + PyMem_Free(wcs_path); |
| 95 | + } |
| 96 | +-#else |
| 97 | +- Tcl_FindExecutable(PyBytes_AS_STRING(cexe)); |
| 98 | +-#endif /* MS_WINDOWS */ |
| 99 | + } |
| 100 | + Py_XDECREF(cexe); |
| 101 | + } |
0 commit comments