[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

STINNER Victor report at bugs.python.org
Tue Mar 29 07:58:44 EDT 2016


STINNER Victor added the comment:

> BTW, with respect to changeset 2b25fa7e3b7a, I'm not sure it has quite the right semantics for is_dir, at least not if it's supposed to parallel os.path.isdir().  I believe that should return True for a symbolic link to a directory, which it doesn't look like this change would, if is_symlink happened to have been called first.  It's possible the semantics of how _DummyDirEntry is used precludes that scenario, but it seems a little fragile.  I'd probably just use lstat() for is_symlink, but otherwise not touch is_dir.

I think that you misunderstood the code. The "use cache lstat" path is only taken if the file is *not* symbolic link.

I tested manually _DummyDirEntry on a symbolic link to a directory: _lstat is filled by the constructor, is_dir() *and* is_symlink() returns True. Both are not exclusive, is_dir() works as follow_symlinks=True, whereas is_symlink() works as follow_symlinks=False.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25911>
_______________________________________


More information about the Python-bugs-list mailing list