Eryk Sun <eryk...@gmail.com> added the comment:

In FileHandler.file_open(), req.host is the host name, which is either None or 
an empty string for a local drive path such as, respectively, 
"file:/Z:/test.py" or "file:///Z:/test.py". The value of req.selector never 
starts with "//", for which file_open() checks, but rather a single slash, such 
as "/Z:/test.py" or "/share/test.py". This is a bug in file_open(). Due to this 
bug, it always calls self.open_local_file(req), even if req.host isn't local. 
The distinction shouldn't matter in Windows, which supports UNC paths, but 
POSIX has to open a path on the local machine (possibly a mount point for a 
remote path, but that's irrelevant). In POSIX, if the local machine 
coincidentally has the req.selector path, then the os.stat() and open() calls 
will succeed with a bogus result.

For "file://host/share/test.py", req.selector is "/share/test.py". In Windows, 
url2pathname() converts this to r"\share\test.py", which is relative to the 
drive of the process current working directory. This is a bug in 
open_local_file() on Windows. For it to work correctly, req.host has to be 
joined back with req.selector as the UNC path "//host/share/test.py". Of 
course, this need not be a local file in Windows, so Windows should be exempted 
from the local file limitation in file_open().

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46654>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to