Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91b5a78

Browse files
committed
Simplify code slightly
1 parent a638202 commit 91b5a78

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/os.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,21 +510,21 @@ def _fwalk(stack, isbytes, topdown, onerror, follow_symlinks):
510510
name = entry.name
511511
if isbytes:
512512
name = fsencode(name)
513-
is_dir = False
513+
514514
try:
515515
is_dir = entry.is_dir()
516-
if is_dir and not topdown:
517-
# Bottom-up: traverse into sub-directory.
518-
stack.append(
519-
(_fwalk_walk, (
520-
False, topfd, topprefix + name, name,
521-
None if follow_symlinks else entry)))
522516
except OSError:
523517
# If is_dir() raises an OSError, consider the entry not to
524518
# be a directory, same behaviour as os.path.isdir().
525-
pass
519+
is_dir = False
526520

527521
if is_dir:
522+
if not topdown:
523+
# Bottom-up: traverse into sub-directory.
524+
stack.append(
525+
(_fwalk_walk, (
526+
False, topfd, topprefix + name, name,
527+
None if follow_symlinks else entry)))
528528
dirs.append(name)
529529
else:
530530
nondirs.append(name)

0 commit comments

Comments
 (0)