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.

Author eryksun
Recipients barneygale, eryksun, ikelos
Date 2022-02-06.01:45:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644111925.95.0.727891586659.issue46654@roundup.psfhosted.org>
In-reply-to
Content
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().
History
Date User Action Args
2022-02-06 01:45:25eryksunsetrecipients: + eryksun, ikelos, barneygale
2022-02-06 01:45:25eryksunsetmessageid: <1644111925.95.0.727891586659.issue46654@roundup.psfhosted.org>
2022-02-06 01:45:25eryksunlinkissue46654 messages
2022-02-06 01:45:25eryksuncreate