Does This Scare You?

eryk sun eryksun at gmail.com
Mon Aug 22 00:17:36 EDT 2016


On Mon, Aug 22, 2016 at 1:26 AM, Chris Angelico <rosuav at gmail.com> wrote:
> They're specifically documented as not touching any file system, which
> means that they are cross-platform and cannot be guaranteed to be
> perfect. If you know you're running on Windows, use WindowsPath
> instead (trying to do so on a non-Windows system will cause an
> immediate exception), and then you can test your examples on that. It
> may well already probe the file system in that situation, and if not,
> you could put forward the feature suggestion that it should. But the
> PurePath classes won't.

PureWindowsPath.is_reserved() delegates to
self._flavour.is_reserved(), and _WindowsFlavour.is_reserved() is the
common implementation. I don't like splitting this up between a pure
and possibly inaccurate version that can be used on Unix systems
versus a concrete and accurate version that can only be used on
Windows. It can certainly be done if people think that's a good idea.

Terry, I'll open an issue that includes the 3 examples I provided plus
anything else I can find. Some patterns may emerge for the handling of
space, dot, and colon that can be used to fix this in a general way.
It would help to consult a reverse-engineered implementation of
RtlGetFullPathName_Ustr  and RtlIsDosDeviceName_Ustr. I'll check the
ReactOS source code.



More information about the Python-list mailing list