This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: islink and stat follow_symlinks are inconsistent on Windows
Type: enhancement Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-01-12 10:42 by eryksun, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (1)
msg285299 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-01-12 10:42
win32_xstat_impl in Modules/posixmodule.c doesn't check the value of reparse_tag to limit traversal to only tags that are considered links. So we have cases in which os.path.islink returns False (e.g. junctions, pending the resolution of issue 23407), but os.stat and os.lstat disagree. For example:

    >>> os.path.islink(r'C:\Documents and Settings')
    False
    >>> s = os.stat(r'C:\Documents and Settings')
    >>> ls = os.lstat(r'C:\Documents and Settings')
    >>> s.st_ino == ls.st_ino
    False

At its strictest, traversal would be limited to just symbolic links. It could be relaxed to also include junctions, and even further to include all tags with the name surrogate bit set [1]. This includes the following Microsoft tags

    IO_REPARSE_TAG_MOUNT_POINT (junctions)
    IO_REPARSE_TAG_SYMLINK
    IO_REPARSE_TAG_IIS_CACHE

and non-Microsoft tags: 

    IO_REPARSE_TAG_SOLUTIONSOFT
    IO_REPARSE_TAG_OSR_SAMPLE
    IO_REPARSE_TAG_QI_TECH_HSM
    IO_REPARSE_TAG_MAXISCALE_HSM

I'm creating this issue as an enhancement for 3.7. The problem has existed for a long time, but it hasn't been a thorn in anyone's side as far as I know.

[1]: https://msdn.microsoft.com/en-us/library/aa365511
History
Date User Action Args
2022-04-11 14:58:41adminsetgithub: 73436
2019-08-22 04:55:31eryksunsetstatus: open -> closed
dependencies: - os.walk always follows Windows junctions
resolution: out of date
stage: needs patch -> resolved
2017-01-12 10:53:22eryksunsetdependencies: + os.walk always follows Windows junctions
2017-01-12 10:42:45eryksuncreate