@@ -72,7 +72,7 @@ def extended_architecture(self) -> Architecture | None:
72
72
class DynamicLibrary :
73
73
soname : str
74
74
path : str | None
75
- realpath : str | None
75
+ realpath : Path | None
76
76
platform : Platform | None = None
77
77
needed : frozenset [str ] = frozenset ()
78
78
@@ -81,7 +81,7 @@ class DynamicLibrary:
81
81
class DynamicExecutable :
82
82
interpreter : str | None
83
83
path : str
84
- realpath : str
84
+ realpath : Path
85
85
platform : Platform
86
86
needed : frozenset [str ]
87
87
rpath : tuple [str , ...]
@@ -354,7 +354,7 @@ def load_ld_paths(root: str = "/", prefix: str = "") -> dict[str, list[str]]:
354
354
355
355
def find_lib (
356
356
platform : Platform , lib : str , ldpaths : list [str ], root : str = "/"
357
- ) -> tuple [str | None , str | None ]:
357
+ ) -> tuple [Path | None , str | None ]:
358
358
"""Try to locate a ``lib`` that is compatible to ``elf`` in the given
359
359
``ldpaths``
360
360
@@ -376,9 +376,9 @@ def find_lib(
376
376
377
377
for ldpath in ldpaths :
378
378
path = os .path .join (ldpath , lib )
379
- target = readlink (path , root , prefixed = True )
379
+ target = Path ( readlink (path , root , prefixed = True ) )
380
380
381
- if os . path . exists (target ):
381
+ if target . exists ():
382
382
with open (target , "rb" ) as f :
383
383
libelf = ELFFile (f )
384
384
if platform .is_compatible (_get_platform (libelf )):
@@ -388,7 +388,7 @@ def find_lib(
388
388
389
389
390
390
def ldd (
391
- path : str ,
391
+ path : Path ,
392
392
root : str = "/" ,
393
393
prefix : str = "" ,
394
394
ldpaths : dict [str , list [str ]] | None = None ,
@@ -481,9 +481,9 @@ def ldd(
481
481
482
482
for t in segment .iter_tags ():
483
483
if t .entry .d_tag == "DT_RPATH" :
484
- rpaths = parse_ld_paths (t .rpath , path = path , root = root )
484
+ rpaths = parse_ld_paths (t .rpath , path = str ( path ) , root = root )
485
485
elif t .entry .d_tag == "DT_RUNPATH" :
486
- runpaths = parse_ld_paths (t .runpath , path = path , root = root )
486
+ runpaths = parse_ld_paths (t .runpath , path = str ( path ) , root = root )
487
487
elif t .entry .d_tag == "DT_NEEDED" :
488
488
needed .add (t .needed )
489
489
if runpaths :
@@ -525,7 +525,7 @@ def ldd(
525
525
_excluded_libs .add (soname )
526
526
continue
527
527
realpath , fullpath = find_lib (platform , soname , all_ldpaths , root )
528
- if realpath is not None and any (fnmatch (realpath , e ) for e in exclude ):
528
+ if realpath is not None and any (fnmatch (str ( realpath ) , e ) for e in exclude ):
529
529
log .info ("Excluding %s" , realpath )
530
530
_excluded_libs .add (soname )
531
531
continue
@@ -544,12 +544,15 @@ def ldd(
544
544
if interpreter is not None :
545
545
soname = os .path .basename (interpreter )
546
546
_all_libs [soname ] = DynamicLibrary (
547
- soname , interpreter , readlink (interpreter , root , prefixed = True ), platform
547
+ soname ,
548
+ interpreter ,
549
+ Path (readlink (interpreter , root , prefixed = True )),
550
+ platform ,
548
551
)
549
552
550
553
return DynamicExecutable (
551
554
interpreter ,
552
- path if display is None else display ,
555
+ str ( path ) if display is None else display ,
553
556
path ,
554
557
platform ,
555
558
frozenset (needed - _excluded_libs ),
0 commit comments