> modified between the two calls? If yes, I don't think that it's an
> issue, it's just good to know it.
>
> For symlinks, readdir() returns the status of the linked file or of the symlink?

I think you're misunderstanding is_dir() and is_file(), as these don't
actually call os.stat(). All DirEntry methods either call nothing or
os.lstat() to get the stat info on the entry itself (not the
destination of the symlink).

Oh. Extract of your PEP: "is_dir(): like os.path.isdir(), but much cheaper".
">

(original) (raw)



Le mardi 8 juillet 2014, Ben Hoyt <benhoyt@gmail.com> a écrit :

\> It is not clear to me which methods share the cache.
\>
\> On UNIX, is\_dir() and is\_file() call os.stat(); whereas lstat() and
\> is\_symlink() call os.lstat().
\>
\> If os.stat() says that the file is not a symlink, I guess that you can
\> use os.stat() result for lstat() and is\_symlink() methods?
\>
\> In the worst case, if the path is a symlink, would it be possible that
\> os.stat() and os.lstat() become "inconsistent" if the symlink is
\> modified between the two calls? If yes, I don't think that it's an
\> issue, it's just good to know it.
\>
\> For symlinks, readdir() returns the status of the linked file or of the symlink?

I think you're misunderstanding is\_dir() and is\_file(), as these don't
actually call os.stat(). All DirEntry methods either call nothing or
os.lstat() to get the stat info on the entry itself (not the
destination of the symlink).

Oh. Extract of your PEP: "is\_dir(): like os.path.isdir(), but much cheaper".

genericpath.isdir() and genericpath.isfile() use os.stat(), whereas posixpath.islink() uses os.lstat().


Is it a mistake in the PEP?

>
In light of this, I don't think what you're describing above is an issue.


I'm not saying that there is an issue, I'm just trying to understand.

Victor