diff --git a/Lib/os.py b/Lib/os.py index a49e7ce4560..e32cd6be32e 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -369,7 +369,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False): # Note that scandir is global in this module due # to earlier import-*. scandir_it = scandir(top) - entries = list(scandir(top)) + entries = list(scandir_it) except OSError as error: if onerror is not None: onerror(error)