Skip to content

Commit

Permalink
Merge pull request #622 from fozziethebeat/fix_permissionerror_order
Browse files Browse the repository at this point in the history
Make sure bitsandbytes handles permission errors in the right order
  • Loading branch information
TimDettmers authored Jan 2, 2024
2 parents e8a42e4 + b4bc336 commit 6ba3e62
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bitsandbytes/cuda_setup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]:
try:
if path.exists():
existent_directories.add(path)
except PermissionError as pex:
# Handle the PermissionError first as it is a subtype of OSError
# https://docs.python.org/3/library/exceptions.html#exception-hierarchy
pass
except OSError as exc:
if exc.errno != errno.ENAMETOOLONG:
raise exc
except PermissionError as pex:
pass

non_existent_directories: Set[Path] = candidate_paths - existent_directories
if non_existent_directories:
Expand Down

0 comments on commit 6ba3e62

Please sign in to comment.