[Python-checkins] bpo-42053: Remove misleading check in os.fwalk() (GH-27669)

serhiy-storchaka webhook-mailer at python.org
Sun Aug 8 14:04:15 EDT 2021

commit: 2b496e79293a8b80e8ba0e514e186b3b1467b64b
branch: main
author: Serhiy Storchaka <storchaka at gmail.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2021-08-08T21:04:02+03:00

bpo-42053: Remove misleading check in os.fwalk() (GH-27669)

os.fwalk() does not support integer as the first argument,
and never supported.

M Lib/os.py

diff --git a/Lib/os.py b/Lib/os.py
index 8cc70a11e9bc8..ab7ef3c17798b 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -461,8 +461,7 @@ def fwalk(top=".", topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=
                 dirs.remove('CVS')  # don't visit CVS directories
         sys.audit("os.fwalk", top, topdown, onerror, follow_symlinks, dir_fd)
-        if not isinstance(top, int) or not hasattr(top, '__index__'):
-            top = fspath(top)
+        top = fspath(top)
         # Note: To guard against symlink races, we use the standard
         # lstat()/open()/fstat() trick.
         if not follow_symlinks:

More information about the Python-checkins mailing list