11import sys
2- import os
3- from pathlib import Path
42from semmle import util
53from semmle .python .passes .objects import ObjectPass
64from semmle .extractors .base import BaseExtractor
@@ -19,7 +17,7 @@ def process(self, unit):
1917 # Modules in the standard library (e.g. `os`)
2018 if not self .options .extract_stdlib and \
2119 isinstance (unit , util .FileExtractable ) and \
22- _is_subpath ( unit .path , util .STDLIB_PATH ):
20+ unit .path . startswith ( util .STDLIB_PATH ):
2321 return SkippedBuiltin
2422 if not isinstance (unit , util .BuiltinModuleExtractable ):
2523 return NotImplemented
@@ -41,18 +39,3 @@ def process(self, unit):
4139
4240 def close (self ):
4341 pass
44-
45- def _is_subpath (path , prefix ):
46- # Prefer filesystem-canonical comparison when possible
47- try :
48- p = Path (path ).resolve ()
49- q = Path (prefix ).resolve ()
50- return p == q or q in p .parents
51- except OSError :
52- # Fallback for non-existent paths: normalize and compare strings
53- p_str = os .path .normcase (os .path .normpath (os .path .abspath (path )))
54- q_str = os .path .normcase (os .path .normpath (os .path .abspath (prefix )))
55- # Ensure prefix is a directory boundary
56- if not q_str .endswith (os .path .sep ):
57- q_str = q_str + os .path .sep
58- return p_str == q_str .rstrip (os .path .sep ) or p_str .startswith (q_str )
0 commit comments