From: Benjamin Peterson Date: Thu, 10 May 2012 21:17:35 +0000 (-0500) Subject: use yield from X-Git-Tag: v3.3.0a4~210 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=569d0875741df1ab196531fb4098b5e5e640aa61;p=thirdparty%2FPython%2Fcpython.git use yield from --- diff --git a/Lib/os.py b/Lib/os.py index 2c7d9548646c..ed2a31e88134 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -294,8 +294,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False): for name in dirs: new_path = join(top, name) if followlinks or not islink(new_path): - for x in walk(new_path, topdown, onerror, followlinks): - yield x + yield from walk(new_path, topdown, onerror, followlinks) if not topdown: yield top, dirs, nondirs @@ -339,8 +338,7 @@ if _exists("openat"): try: if (followlinks or (st.S_ISDIR(orig_st.st_mode) and path.samestat(orig_st, fstat(topfd)))): - for x in _fwalk(topfd, top, topdown, onerror, followlinks): - yield x + yield from _fwalk(topfd, top, topdown, onerror, followlinks) finally: close(topfd) @@ -377,8 +375,7 @@ if _exists("openat"): try: if followlinks or path.samestat(orig_st, fstat(dirfd)): dirpath = path.join(toppath, name) - for x in _fwalk(dirfd, dirpath, topdown, onerror, followlinks): - yield x + yield from _fwalk(dirfd, dirpath, topdown, onerror, followlinks) finally: close(dirfd)