Steve Dower <steve.do...@python.org> added the comment:

> Given the only option here is follow_symlinks, then the first CreateFileW 
> call in win32_xstat_impl should only open a reparse point if follow_symlinks 
> is false. In this case, if it happens to open a reparse point that's not a 
> symlink, it should try to reopen with reparsing enabled. In either case, if 
> reparsing fails because a reparse point isn't handled 
> (ERROR_CANT_ACCESS_FILE), try to open the reparse point itself. The latter 
> would be the second open attempt if follow_symlinks is true and the third 
> open attempt if follow_symlinks is false. 
>
> If a reparse point isn't handled, then there's nothing in principle that 
> stat() could ever follow. Given that it's impractical to fail in this case, 
> considering how much code would have to be modified, then the above 
> compromise should suffice.

This sounds like reasonable logic. I'll take a look at updating my PR.

> In the proposed implementation of realpath() that I helped on for issue 14094

I totally forgot about this issue and the PR (but it looks like the contributor 
did too). I just posted PR 15287 today with the tests from the patch on 
issue9949 and it's looking okay - certainly an improvement over the current 
behaviour. But it doesn't have the change to readlink() that would add the \\?\ 
prefix, which means it doesn't answer that question.

> I wish we could remove the MAX_PATH limit in this case.

The problem is that we have to remove the limit in any case where the resulting 
path might be used, which is what we're already trying to encourage by 
supporting long paths.

Perhaps the best we can do is an additional test where we GetFinalPathName, 
strip the prefix, reopen the file, GetFinalPathName again and if they match 
then return it without the prefix. That should handle the both long path 
settings as transparently as we can.

----------

_______________________________________
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

Reply via email to