Skip to content

Commit 72c034b

Browse files
committed
Fix needless try/except around is_dir() while we're here
1 parent 87d37e3 commit 72c034b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Lib/pathlib/_abc.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,11 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
316316
paths.append((path, dirnames, filenames))
317317
try:
318318
for child in path.iterdir():
319-
try:
320-
if child.info.is_dir(follow_symlinks=follow_symlinks):
321-
if not top_down:
322-
paths.append(child)
323-
dirnames.append(child.name)
324-
else:
325-
filenames.append(child.name)
326-
except OSError:
319+
if child.info.is_dir(follow_symlinks=follow_symlinks):
320+
if not top_down:
321+
paths.append(child)
322+
dirnames.append(child.name)
323+
else:
327324
filenames.append(child.name)
328325
except OSError as error:
329326
if on_error is not None:

0 commit comments

Comments
 (0)