@@ -72,7 +72,7 @@ def extended_architecture(self) -> Architecture | None:
7272class DynamicLibrary :
7373 soname : str
7474 path : str | None
75- realpath : str | None
75+ realpath : Path | None
7676 platform : Platform | None = None
7777 needed : frozenset [str ] = frozenset ()
7878
@@ -81,7 +81,7 @@ class DynamicLibrary:
8181class DynamicExecutable :
8282 interpreter : str | None
8383 path : str
84- realpath : str
84+ realpath : Path
8585 platform : Platform
8686 needed : frozenset [str ]
8787 rpath : tuple [str , ...]
@@ -354,7 +354,7 @@ def load_ld_paths(root: str = "/", prefix: str = "") -> dict[str, list[str]]:
354354
355355def find_lib (
356356 platform : Platform , lib : str , ldpaths : list [str ], root : str = "/"
357- ) -> tuple [str | None , str | None ]:
357+ ) -> tuple [Path | None , str | None ]:
358358 """Try to locate a ``lib`` that is compatible to ``elf`` in the given
359359 ``ldpaths``
360360
@@ -376,9 +376,9 @@ def find_lib(
376376
377377 for ldpath in ldpaths :
378378 path = os .path .join (ldpath , lib )
379- target = readlink (path , root , prefixed = True )
379+ target = Path ( readlink (path , root , prefixed = True ) )
380380
381- if os . path . exists (target ):
381+ if target . exists ():
382382 with open (target , "rb" ) as f :
383383 libelf = ELFFile (f )
384384 if platform .is_compatible (_get_platform (libelf )):
@@ -388,7 +388,7 @@ def find_lib(
388388
389389
390390def ldd (
391- path : str ,
391+ path : Path ,
392392 root : str = "/" ,
393393 prefix : str = "" ,
394394 ldpaths : dict [str , list [str ]] | None = None ,
@@ -481,9 +481,9 @@ def ldd(
481481
482482 for t in segment .iter_tags ():
483483 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 )
485485 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 )
487487 elif t .entry .d_tag == "DT_NEEDED" :
488488 needed .add (t .needed )
489489 if runpaths :
@@ -525,7 +525,7 @@ def ldd(
525525 _excluded_libs .add (soname )
526526 continue
527527 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 ):
529529 log .info ("Excluding %s" , realpath )
530530 _excluded_libs .add (soname )
531531 continue
@@ -544,12 +544,15 @@ def ldd(
544544 if interpreter is not None :
545545 soname = os .path .basename (interpreter )
546546 _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 ,
548551 )
549552
550553 return DynamicExecutable (
551554 interpreter ,
552- path if display is None else display ,
555+ str ( path ) if display is None else display ,
553556 path ,
554557 platform ,
555558 frozenset (needed - _excluded_libs ),
0 commit comments