Skip to content

Commit

Permalink
autoimport/sqlite.py: python3.13 iterdir() raises PermissionError
Browse files Browse the repository at this point in the history
The PermissionError is now raised earlier when we initialize the iterdir
object instead of when we attempt to get the next()

Closes: #801
Signed-off-by: Nowa Ammerlaan <nowa@gentoo.org>
  • Loading branch information
Nowa-Ammerlaan committed Jan 2, 2025
1 parent 8bb4ac0 commit 90e2451
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rope/contrib/autoimport/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,17 @@ def filter_folders(folder: Path) -> bool:
return list(OrderedDict.fromkeys(folder_paths))

def _safe_iterdir(self, folder: Path):
dirs = folder.iterdir()
while True:
try:
yield next(dirs)
except PermissionError:
pass
except StopIteration:
break
try:
dirs = folder.iterdir()
while True:
try:
yield next(dirs)
except PermissionError:
pass
except StopIteration:
break
except PermissionError:
pass

def _get_available_packages(self) -> List[Package]:
packages: List[Package] = [
Expand Down

0 comments on commit 90e2451

Please sign in to comment.