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

> So essentially, you say the check should always be "ntpath.isdir(d) 

I forgot that ntpath.isdir is now genericpath.isdir, so that will work. The old 
nt._isdir wouldn't work because it was equivalent to an lstat. Apparently a 
vestigial import of nt._isdir remains in ntpath.py, even though nt._isdir was 
removed:

https://hg.python.org/cpython/file/v3.3.0/Lib/ntpath.py#l677

> On the other hand, this will make ntpath.ismount meaningless on POSIX, 
> as it will always require real access to the file system. Is it worth 
> having a "pure" implementation for best effort in this case? 

I'm not suggesting an existence check in POSIX. Whoever uses ntpath in POSIX 
must be aware that ntpath.ismount is useless for detecting Unix mount points. 
It's only useful for identifying potential mount points in a pure Windows path. 
I see no reason to break this use case.

For POSIX, I'd like ntpath._abspath_fallback to handle drive-relative paths, so 
we can fix the check in ismount to use `rest and rest in seps`. It seems wrong 
for _abspath_fallback("F:") to return the relative path "F:". No drives exist 
in POSIX, so it's harmless to assume that the working directory on each drive 
is the root directory, which is the default value in Windows anyway.

> Based on the splitdrive() 

Note that splitdrive currently doesn't support "UNC" device paths (issue 
37609). For example, "//?/UNC/server/share" splits as ("//?/UNC", 
"/server/share"). "GLOBAL" device paths also aren't supported, which I'd 
prefer, but it's less important because they're only useful rarely, and I don't 
know of an existing path library that handles them. splitdrive also doesn't 
support repeated separators between the server and share components, such as 
"//server///share", which GetFullPathNameW handles nowadays. Maybe it didn't 
circa NT 5.0. The only place that's strict is the UNC root, which must be 
exactly two separators. I uploaded an implementation to issue 37609 that 
supports "UNC" and "GLOBAL" device paths, with support for repeated separators. 
Here's a complex example split: ("//?///Global///UNC///server///share", 
"///path").

Anyway, ntpath.ismount needs to distinguish between UNC and "UNC" device paths 
vs all other device paths, because a root path is only optional in the UNC 
case. For example, "//?/C:" or "//?/BootPartition" is a volume device, and 
"//?C:/" or "//?/BootPartition/" is a filesystem mount point. In Windows we can 
detect that "//?/C:" or "//?/BootPartition" isn't a directory, but in POSIX we 
need to get it right as a pure path.

----------

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

Reply via email to