File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,7 +57,12 @@ def __init__(
5757 venv = os .environ .get ("VIRTUAL_ENV" )
5858 if venv :
5959 bin_dir = "Scripts" if os .name == "nt" else "bin"
60- venv_path = Path (venv ).resolve () / bin_dir
60+ try :
61+ venv_path = Path (venv ).resolve () / bin_dir
62+ except (PermissionError , OSError ):
63+ # resolve() can raise PermissionError on Windows for restricted
64+ # system directories; fall back to a non-resolving join.
65+ venv_path = Path (venv ) / bin_dir
6166
6267 # For Windows tests with Unix-style paths
6368 if os .name == "nt" and str (venv ).startswith ("/" ):
Original file line number Diff line number Diff line change @@ -238,11 +238,14 @@ def exists_and_is_accessible(path: Path) -> bool:
238238 """
239239 try :
240240 return path .exists ()
241- except PermissionError as pe :
242- if pe .errno == errno .EACCES : # Permission denied
243- return False
244- else :
245- raise
241+ except PermissionError :
242+ # Treat any permission-denied error (including Windows WinError 5) as
243+ # inaccessible rather than crashing.
244+ return False
245+ except OSError :
246+ # Catch other OS-level errors (e.g. Windows ERROR_ACCESS_DENIED variants
247+ # that may surface as OSError rather than PermissionError).
248+ return False
246249
247250
248251def is_in_path (path : str | Path , parent_path : str | Path ) -> bool :
You can’t perform that action at this time.
0 commit comments