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

Skip to content

Commit 033c3f2

Browse files
committed
Merge pull request #7433 from matthew-brett/master
FIX: search for tkinter first in builtins
1 parent a3d7af4 commit 033c3f2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/_tkagg.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,19 @@ int load_tkinter_funcs(void)
408408
// Load tkinter global funcs from tkinter compiled module.
409409
// Return 0 for success, non-zero for failure.
410410
int ret = -1;
411-
void *tkinter_lib;
411+
void *main_program, *tkinter_lib;
412412
char *tkinter_libname;
413413
PyObject *pModule = NULL, *pSubmodule = NULL, *pString = NULL;
414414

415+
// Try loading from the main program namespace first
416+
main_program = dlopen(NULL, RTLD_LAZY);
417+
if (_func_loader(main_program) == 0) {
418+
return 0;
419+
}
420+
// Clear exception triggered when we didn't find symbols above.
421+
PyErr_Clear();
422+
423+
// Now try finding the tkinter compiled module
415424
pModule = PyImport_ImportModule(TKINTER_PKG);
416425
if (pModule == NULL) {
417426
goto exit;

0 commit comments

Comments
 (0)