Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Prev Previous commit
Next Next commit
Attempted fix for Ubuntu failure
  • Loading branch information
E-Paine committed Jul 19, 2020
commit 93297b651193069457ac798f3950dbbc25726b2b
9 changes: 4 additions & 5 deletions Lib/tkinter/test/test_tkinter/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ def test_thread_gc(self):
stdout, stderr = p.communicate()
stderr = stderr.strip()
try:
self.assertEqual(stderr,
b"Exception ignored in: 'Deallocation of Tkapp "
b"attempted in wrong thread. Skipping deletion of "
b"Tcl interpreter (this will cause a memory "
b"leak).'")
self.assertTrue(b"Exception ignored in: <class 'RuntimeWarning'>" in stderr)
self.assertTrue(b"RuntimeWarning: Deallocation of Tkapp attempted in wrong "
b"thread. Skipping deletion of Tcl interpreter (this will "
b"cause a memory leak)." in stderr)
except AssertionError:
# If there is an error in the subprocess
# we need to be able to debug it
Expand Down
6 changes: 4 additions & 2 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3043,9 +3043,11 @@ Tkapp_Dealloc(PyObject *self)
if (((TkappObject *)self)->threaded && \
((TkappObject *)self)->thread_id != Tcl_GetCurrentThread()) {
// We cannot delete the interpreter in the wrong thread (bpo-39093)
PyErr_WriteUnraisable(PyUnicode_FromString("Deallocation of Tkapp " \
PyErr_SetString(PyExc_RuntimeWarning, "Deallocation of Tkapp " \
"attempted in wrong thread. Skipping deletion of Tcl " \
"interpreter (this will cause a memory leak)."));
"interpreter (this will cause a memory leak).");
PyErr_WriteUnraisable(PyErr_Occurred());
PyErr_Clear();
} else {
ENTER_TCL
Tcl_DeleteInterp(Tkapp_Interp(self));
Expand Down