File tree 1 file changed +8
-13
lines changed
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) {
364
364
* tkinter dynamic library (module).
365
365
*/
366
366
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
-
378
367
#include <dlfcn.h>
379
368
380
369
void *
@@ -442,7 +431,7 @@ load_tkinter_funcs(void) {
442
431
int ret = -1 ;
443
432
void * main_program , * tkinter_lib ;
444
433
char * tkinter_libname ;
445
- PyObject * pModule = NULL , * pString = NULL ;
434
+ PyObject * pModule = NULL , * pString = NULL , * pBytes = NULL ;
446
435
447
436
/* Try loading from the main program namespace first */
448
437
main_program = dlopen (NULL , RTLD_LAZY );
@@ -462,7 +451,12 @@ load_tkinter_funcs(void) {
462
451
if (pString == NULL ) {
463
452
goto exit ;
464
453
}
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 );
466
460
if (tkinter_libname == NULL ) {
467
461
goto exit ;
468
462
}
@@ -478,6 +472,7 @@ load_tkinter_funcs(void) {
478
472
dlclose (main_program );
479
473
Py_XDECREF (pModule );
480
474
Py_XDECREF (pString );
475
+ Py_XDECREF (pBytes );
481
476
return ret ;
482
477
}
483
478
#endif /* end not Windows */
You can’t perform that action at this time.
0 commit comments