Commit 569d0875 authored by Benjamin Peterson's avatar Benjamin Peterson

use yield from

parent e8751e05
...@@ -294,8 +294,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False): ...@@ -294,8 +294,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
for name in dirs: for name in dirs:
new_path = join(top, name) new_path = join(top, name)
if followlinks or not islink(new_path): if followlinks or not islink(new_path):
for x in walk(new_path, topdown, onerror, followlinks): yield from walk(new_path, topdown, onerror, followlinks)
yield x
if not topdown: if not topdown:
yield top, dirs, nondirs yield top, dirs, nondirs
...@@ -339,8 +338,7 @@ if _exists("openat"): ...@@ -339,8 +338,7 @@ if _exists("openat"):
try: try:
if (followlinks or (st.S_ISDIR(orig_st.st_mode) and if (followlinks or (st.S_ISDIR(orig_st.st_mode) and
path.samestat(orig_st, fstat(topfd)))): path.samestat(orig_st, fstat(topfd)))):
for x in _fwalk(topfd, top, topdown, onerror, followlinks): yield from _fwalk(topfd, top, topdown, onerror, followlinks)
yield x
finally: finally:
close(topfd) close(topfd)
...@@ -377,8 +375,7 @@ if _exists("openat"): ...@@ -377,8 +375,7 @@ if _exists("openat"):
try: try:
if followlinks or path.samestat(orig_st, fstat(dirfd)): if followlinks or path.samestat(orig_st, fstat(dirfd)):
dirpath = path.join(toppath, name) dirpath = path.join(toppath, name)
for x in _fwalk(dirfd, dirpath, topdown, onerror, followlinks): yield from _fwalk(dirfd, dirpath, topdown, onerror, followlinks)
yield x
finally: finally:
close(dirfd) close(dirfd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment