Eryk Sun <[email protected]> added the comment:
> When strict is "false", pathlib should not fail if the network
> share is inaccessible.
A redirected filesystem (i.e. a share, whether local or remote) that's
physically inaccessible should fail with a FileNotFoundError -- due to
underlying errors such as ERROR_BAD_NETPATH (53) or ERROR_BAD_NET_NAME (67).
This case is already handled by resolve() in non-strict mode. But error
handling for other cases does need to be expanded.
A PermissionError should be ignored, from OS errors such as ERROR_ACCESS_DENIED
(5), ERROR_SHARING_VIOLATION (32), and ERROR_NOT_READY (21).
It should ignore errors due to bad reparse points (e.g. filesystem symlinks and
mount points), such as ERROR_INVALID_REPARSE_DATA (4392) and
ERROR_REPARSE_TAG_INVALID (4393).
The resolve() method is supposed to raise a RuntimeError for a symlink loop
(i.e. reparse loop). In Windows, the system detects this case as
ERROR_CANT_RESOLVE_FILENAME (1921). It's not necessarily due to a reparse loop,
but in practice it usually is. (It's actually due to the upper limit for the
number of reparse attempts, which as of Windows 10 is no more than 63
attempts.) Maybe this error should be re-raised as a RuntimeError for the sake
of compatibility with the POSIX implementation.
The above-mentioned cases are all due to WINAPI CreateFileW failing.
Additionally, the GetFinalPathNameByHandleW call in nt._getfinalpathname relies
on several low-level system calls, any one of which can fail with
ERROR_INVALID_FUNCTION (1) or ERROR_INVALID_PARAMETER (87) -- and possibly
ERROR_NOT_SUPPORTED (50). These errors should be ignored in non-strict mode.
At a lower level, the reliability of nt._getfinalpathname could be improved for
non-strict operation. It could fall back on other forms of the final name that
may be supported. It could try FILE_NAME_OPENED instead of FILE_NAME_NORMALIZED
to handle a filesystem that does not support normalizing 8.3 short names as
long names. Try VOLUME_NAME_GUID instead of VOLUME_NAME_DOS to handle a volume
that only has a GUID name (i.e. a volume device that's registered with the
mount-point manager but lacks a DOS drive name or even a mountpoint on a volume
that has a DOS drive name). Try VOLUME_NAME_NT to handle legacy
volume/filesystem devices ('legacy' because they do not support the mount-point
manager interface that was introduced almost 20 years ago in NT 5). For the
sake of simplicity and performance, the latter case could be limited to
well-known DOS device names such as r"\\?\PIPE" -> r"\Device\NamedPipe". The NT
device path for the comparison should be queried instead of hard coded, e.g.
via QueryDosDeviceW(L"PIPE", ...).
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31842>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com