Skip to content

Commit a82623e

Browse files
committed
Handle OSError again when iterating directories
1 parent 12e9ce1 commit a82623e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bpython/importcompletion.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,17 @@ def find_modules(self, path):
136136
# Path is on skiplist
137137
return
138138

139+
try:
140+
# https://bugs.python.org/issue34541
141+
# Once we migrate to Python 3.8, we can change it back to directly iterator over
142+
# path.iterdir().
143+
children = tuple(path.iterdir())
144+
except OSError:
145+
# Path is not readable
146+
return
147+
139148
finder = importlib.machinery.FileFinder(str(path))
140-
for p in path.iterdir():
149+
for p in children:
141150
if any(fnmatch.fnmatch(p.name, entry) for entry in self.skiplist):
142151
# Path is on skiplist
143152
continue

0 commit comments

Comments
 (0)