From 92272f81954e2ce38a81071ba9072dd98bd89ee3 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Wed, 9 Nov 2016 08:58:12 -0800 Subject: [PATCH] FIX: search for tkinter first in builtins Python compiled from Python.org source builds the tkinter module as a built-in module, not an external module, as is the case for the packaged builds of Debian etc: >>> Tkinter.tkinter This breaks the current algorithm for searching for tkinter symbols, which loaded the external module .so file to get the symbols. Try searching in the main program namespace for the tkinter symbols, before looking for the extermal module .so file. Thanks to github user ettaka for reporting : see https://github.com/matplotlib/matplotlib/issues/7428 --- Tk/tkImaging.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Tk/tkImaging.c b/Tk/tkImaging.c index 5999a140a..6c612cfe9 100644 --- a/Tk/tkImaging.c +++ b/Tk/tkImaging.c @@ -438,10 +438,19 @@ int load_tkinter_funcs(void) */ int ret = -1; - void *tkinter_lib; + void *main_program, *tkinter_lib; char *tkinter_libname; PyObject *pModule = NULL, *pString = NULL; + /* Try loading from the main program namespace first */ + main_program = dlopen(NULL, RTLD_LAZY); + if (_func_loader(main_program) == 0) { + return 0; + } + /* Clear exception triggered when we didn't find symbols above */ + PyErr_Clear(); + + /* Now try finding the tkinter compiled module */ pModule = PyImport_ImportModule(TKINTER_FINDER); if (pModule == NULL) { goto exit;