diff options
author | Brett Cannon <brett@python.org> | 2016-08-26 21:44:48 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2016-08-26 21:44:48 (GMT) |
commit | 3f9183b5aca568867f37c38501fca63911580c66 (patch) | |
tree | 77dbe8fa7c0381c665ed259a94620a860a8f73d7 /Lib/os.py | |
parent | 6ed442c48dd7f8d3097e688a36bc027df3271621 (diff) | |
download | cpython-3f9183b5aca568867f37c38501fca63911580c66.zip cpython-3f9183b5aca568867f37c38501fca63911580c66.tar.gz cpython-3f9183b5aca568867f37c38501fca63911580c66.tar.bz2 |
Issue #26027, #27524: Add PEP 519/__fspath__() support to os and
os.path.
Thanks to Jelle Zijlstra for the initial patch against posixmodule.c.
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -353,7 +353,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False): dirs.remove('CVS') # don't visit CVS directories """ - + top = fspath(top) dirs = [] nondirs = [] walk_dirs = [] @@ -536,6 +536,8 @@ if {open, stat} <= supports_dir_fd and {listdir, stat} <= supports_fd: if 'CVS' in dirs: dirs.remove('CVS') # don't visit CVS directories """ + if not isinstance(top, int) or not hasattr(top, '__index__'): + top = fspath(top) # Note: To guard against symlink races, we use the standard # lstat()/open()/fstat() trick. orig_st = stat(top, follow_symlinks=False, dir_fd=dir_fd) |