File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -364,17 +364,6 @@ load_tkinter_funcs(void) {
364364 * tkinter dynamic library (module).
365365 */
366366
367- /* From module __file__ attribute to char *string for dlopen. */
368- char *
369- fname2char (PyObject * fname ) {
370- PyObject * bytes ;
371- bytes = PyUnicode_EncodeFSDefault (fname );
372- if (bytes == NULL ) {
373- return NULL ;
374- }
375- return PyBytes_AsString (bytes );
376- }
377-
378367#include <dlfcn.h>
379368
380369void *
@@ -442,7 +431,7 @@ load_tkinter_funcs(void) {
442431 int ret = -1 ;
443432 void * main_program , * tkinter_lib ;
444433 char * tkinter_libname ;
445- PyObject * pModule = NULL , * pString = NULL ;
434+ PyObject * pModule = NULL , * pString = NULL , * pBytes = NULL ;
446435
447436 /* Try loading from the main program namespace first */
448437 main_program = dlopen (NULL , RTLD_LAZY );
@@ -462,7 +451,12 @@ load_tkinter_funcs(void) {
462451 if (pString == NULL ) {
463452 goto exit ;
464453 }
465- tkinter_libname = fname2char (pString );
454+ /* From module __file__ attribute to char *string for dlopen. */
455+ pBytes = PyUnicode_EncodeFSDefault (pString );
456+ if (pBytes == NULL ) {
457+ goto exit ;
458+ }
459+ tkinter_libname = PyBytes_AsString (pBytes );
466460 if (tkinter_libname == NULL ) {
467461 goto exit ;
468462 }
@@ -478,6 +472,7 @@ load_tkinter_funcs(void) {
478472 dlclose (main_program );
479473 Py_XDECREF (pModule );
480474 Py_XDECREF (pString );
475+ Py_XDECREF (pBytes );
481476 return ret ;
482477}
483478#endif /* end not Windows */
You can’t perform that action at this time.
0 commit comments