Steve Dower <steve.do...@python.org> added the comment:
> So we _do_ want to "upgrade" lstat() to stat() when it's not a symlink. Except this bug came about because we want to _downgrade_ stat() to lstat() when it's an appexeclink, because the whole point of those is to use them without following them (and yeah, most operations are going to fail, but they'd fail against the target file too). So we have this logic: def xstat(path, traverse): f = open(path, flags | (0 if traverse else OPEN_REPARSE_POINT)) if !f: # Special case for appexeclink if traverse and ERROR_CANT_OPEN_FILE: st = xstat(path, !traverse) if st.reparse_tag == APPEXECLINC: return st raise ERROR_CANT_OPEN_FILE # Handle "likely" errors if ERROR_ACCESS_DENIED or SHARING_VIOLATION: st = read_from_dir(os.path.split(path)) else: st = read_from_file(f) # Always make the OS resolve "unknown" reparse points ALLOWED_TO_TRAVERSE = {SYMLINK, MOUNT_POINT} if !traverse and st.reparse_tag not in ALLOWED_TO_TRAVERSE: return xstat(path, !traverse) return st And the open question is just whether MOUNT_POINT should be in that set near the end. I believe it should, since the alternative is to force all Python developers to write special Windows-only code to handle directory junctions. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37834> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com