Steve Dower <> 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
            st = read_from_dir(os.path.split(path))
        st = read_from_file(f)

    # Always make the OS resolve "unknown" reparse points
    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 <>
Python-bugs-list mailing list

Reply via email to