Skip to content

Commit ae0fa22

Browse files
committed
Convert to UTF-8 prior to setting Tkinter path
1 parent b545a9f commit ae0fa22

File tree

5 files changed

+41
-18
lines changed

5 files changed

+41
-18
lines changed

cpython-unix/patch-tkinter-3.10.patch

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
2-
index 2a3e65b6c97..b17c5bfd6b1 100644
2+
index 2a3e65b6c97..04f2ab0ea10 100644
33
--- a/Modules/_tkinter.c
44
+++ b/Modules/_tkinter.c
55
@@ -115,6 +115,7 @@ Copyright (C) 1994 Steen Lumholt.
@@ -82,7 +82,7 @@ index 2a3e65b6c97..b17c5bfd6b1 100644
8282
str_path = _get_tcl_lib_path();
8383
if (str_path == NULL && PyErr_Occurred()) {
8484
return NULL;
85-
@@ -3628,7 +3674,27 @@ PyInit__tkinter(void)
85+
@@ -3628,7 +3674,32 @@ PyInit__tkinter(void)
8686
PyMem_Free(wcs_path);
8787
}
8888
#else
@@ -97,6 +97,11 @@ index 2a3e65b6c97..b17c5bfd6b1 100644
9797
+ return NULL;
9898
+ }
9999
+ if (str_path != NULL) {
100+
+ path = PyUnicode_AsUTF8(str_path);
101+
+ if (path == NULL) {
102+
+ Py_DECREF(m);
103+
+ return NULL;
104+
+ }
100105
+ setenv("TCL_LIBRARY", path, 1);
101106
+ set_var = 1;
102107
+ }

cpython-unix/patch-tkinter-3.11.patch

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
2-
index 005036d3ff2..c130ed7b186 100644
2+
index 005036d3ff2..91289c16616 100644
33
--- a/Modules/_tkinter.c
44
+++ b/Modules/_tkinter.c
55
@@ -28,9 +28,7 @@ Copyright (C) 1994 Steen Lumholt.
@@ -9,7 +9,7 @@ index 005036d3ff2..c130ed7b186 100644
99
-#ifdef MS_WINDOWS
1010
-# include "pycore_fileutils.h" // _Py_stat()
1111
-#endif
12-
+#include "pycore_fileutils.h" // _Py_stat()
12+
+#include "pycore_fileutils.h"
1313

1414
#ifdef MS_WINDOWS
1515
#include <windows.h>
@@ -21,15 +21,16 @@ index 005036d3ff2..c130ed7b186 100644
2121

2222
static PyObject *
2323
_get_tcl_lib_path()
24-
@@ -140,6 +139,7 @@ _get_tcl_lib_path()
24+
@@ -139,7 +138,7 @@ _get_tcl_lib_path()
25+
if (prefix == NULL) {
2526
return NULL;
2627
}
27-
28+
-
2829
+#ifdef MS_WINDOWS
2930
/* Check expected location for an installed Python first */
3031
tcl_library_path = PyUnicode_FromString("\\tcl\\tcl" TCL_VERSION);
3132
if (tcl_library_path == NULL) {
32-
@@ -177,11 +177,31 @@ _get_tcl_lib_path()
33+
@@ -177,11 +176,31 @@ _get_tcl_lib_path()
3334
tcl_library_path = NULL;
3435
#endif
3536
}
@@ -62,7 +63,7 @@ index 005036d3ff2..c130ed7b186 100644
6263

6364
/* The threading situation is complicated. Tcl is not thread-safe, except
6465
when configured with --enable-threads.
65-
@@ -687,6 +707,30 @@ Tkapp_New(const char *screenName, const char *className,
66+
@@ -687,6 +706,30 @@ Tkapp_New(const char *screenName, const char *className,
6667

6768
ret = GetEnvironmentVariableW(L"TCL_LIBRARY", NULL, 0);
6869
if (!ret && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
@@ -93,7 +94,7 @@ index 005036d3ff2..c130ed7b186 100644
9394
str_path = _get_tcl_lib_path();
9495
if (str_path == NULL && PyErr_Occurred()) {
9596
return NULL;
96-
@@ -3428,7 +3472,27 @@ PyInit__tkinter(void)
97+
@@ -3428,7 +3471,32 @@ PyInit__tkinter(void)
9798
PyMem_Free(wcs_path);
9899
}
99100
#else
@@ -108,6 +109,11 @@ index 005036d3ff2..c130ed7b186 100644
108109
+ return NULL;
109110
+ }
110111
+ if (str_path != NULL) {
112+
+ path = PyUnicode_AsUTF8(str_path);
113+
+ if (path == NULL) {
114+
+ Py_DECREF(m);
115+
+ return NULL;
116+
+ }
111117
+ setenv("TCL_LIBRARY", path, 1);
112118
+ set_var = 1;
113119
+ }

cpython-unix/patch-tkinter-3.12.patch

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
2-
index 6b5fcb8a365..99d44ccf1d8 100644
2+
index 6b5fcb8a365..7b196f40166 100644
33
--- a/Modules/_tkinter.c
44
+++ b/Modules/_tkinter.c
55
@@ -28,9 +28,7 @@ Copyright (C) 1994 Steen Lumholt.
@@ -93,7 +93,7 @@ index 6b5fcb8a365..99d44ccf1d8 100644
9393
str_path = _get_tcl_lib_path();
9494
if (str_path == NULL && PyErr_Occurred()) {
9595
return NULL;
96-
@@ -3542,7 +3586,27 @@ PyInit__tkinter(void)
96+
@@ -3542,7 +3586,32 @@ PyInit__tkinter(void)
9797
PyMem_Free(wcs_path);
9898
}
9999
#else
@@ -108,6 +108,11 @@ index 6b5fcb8a365..99d44ccf1d8 100644
108108
+ return NULL;
109109
+ }
110110
+ if (str_path != NULL) {
111+
+ path = PyUnicode_AsUTF8(str_path);
112+
+ if (path == NULL) {
113+
+ Py_DECREF(m);
114+
+ return NULL;
115+
+ }
111116
+ setenv("TCL_LIBRARY", path, 1);
112117
+ set_var = 1;
113118
+ }

cpython-unix/patch-tkinter-3.13.patch

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
2-
index 45897817a56..671b3dfc3d0 100644
2+
index 45897817a56..5633187730a 100644
33
--- a/Modules/_tkinter.c
44
+++ b/Modules/_tkinter.c
55
@@ -26,9 +26,8 @@ Copyright (C) 1994 Steen Lumholt.
@@ -94,7 +94,7 @@ index 45897817a56..671b3dfc3d0 100644
9494
str_path = _get_tcl_lib_path();
9595
if (str_path == NULL && PyErr_Occurred()) {
9696
return NULL;
97-
@@ -3552,7 +3597,27 @@ PyInit__tkinter(void)
97+
@@ -3552,7 +3597,32 @@ PyInit__tkinter(void)
9898
PyMem_Free(wcs_path);
9999
}
100100
#else
@@ -109,6 +109,11 @@ index 45897817a56..671b3dfc3d0 100644
109109
+ return NULL;
110110
+ }
111111
+ if (str_path != NULL) {
112+
+ path = PyUnicode_AsUTF8(str_path);
113+
+ if (path == NULL) {
114+
+ Py_DECREF(m);
115+
+ return NULL;
116+
+ }
112117
+ setenv("TCL_LIBRARY", path, 1);
113118
+ set_var = 1;
114119
+ }
@@ -122,6 +127,3 @@ index 45897817a56..671b3dfc3d0 100644
122127
#endif /* MS_WINDOWS */
123128
}
124129
Py_XDECREF(cexe);
125-
diff --git a/patch-tkinter.patch b/patch-tkinter.patch
126-
new file mode 100644
127-
index 00000000000..e69de29bb2d

cpython-unix/patch-tkinter-3.9.patch

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
2-
index e153047b778..5dbaf2e3e6e 100644
2+
index e153047b778..02f5d12db1a 100644
33
--- a/Modules/_tkinter.c
44
+++ b/Modules/_tkinter.c
55
@@ -115,6 +115,7 @@ Copyright (C) 1994 Steen Lumholt.
@@ -82,7 +82,7 @@ index e153047b778..5dbaf2e3e6e 100644
8282
str_path = _get_tcl_lib_path();
8383
if (str_path == NULL && PyErr_Occurred()) {
8484
return NULL;
85-
@@ -3631,7 +3677,27 @@ PyInit__tkinter(void)
85+
@@ -3631,7 +3677,32 @@ PyInit__tkinter(void)
8686
PyMem_Free(wcs_path);
8787
}
8888
#else
@@ -97,6 +97,11 @@ index e153047b778..5dbaf2e3e6e 100644
9797
+ return NULL;
9898
+ }
9999
+ if (str_path != NULL) {
100+
+ path = PyUnicode_AsUTF8(str_path);
101+
+ if (path == NULL) {
102+
+ Py_DECREF(m);
103+
+ return NULL;
104+
+ }
100105
+ setenv("TCL_LIBRARY", path, 1);
101106
+ set_var = 1;
102107
+ }

0 commit comments

Comments
 (0)