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 izbyshev
Recipients eryksun, izbyshev, miss-islington, paul.moore, steve.dower, tim.golden, zach.ware
Date 2018-03-08.22:29:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520548198.4.0.467229070634.issue33016@psf.upfronthosting.co.za>
In-reply-to
Content
Copying the comment of @eryksun from PR 6010 for reference.

Because we only try VOLUME_NAME_DOS, this function always fails for a volume that's not mounted as either a drive letter or a junction mount point. The error in this case is ERROR_PATH_NOT_FOUND. We know that the path is valid because we have a handle (in this case the file system ensures that no parent directory in the path can be unlinked or renamed). To address this, if the flags parameter isn't already VOLUME_NAME_GUID, it could switch to it and continue the while loop (no need to realloc). Otherwise if it's already VOLUME_NAME_GUID or for any other error, the call should fail.

For DOS devices in paths (e.g. "C:\Temp\NUL"), CreateFile commonly succeeds, but GetFinalPathNameByHandle commonly fails with either ERROR_INVALID_FUNCTION or ERROR_INVALID_PARAMETER. What do you think about handling this failure by calling GetFullPathName instead (e.g. "C:\Temp\NUL" => "\\.\NUL")? That way most DOS device paths won't cause this function to fail (e.g. when called by pathlib's resolve method). We could do the same if CreateFile fails with ERROR_INVALID_PARAMETER, which should only occur for CON (e.g. "C:\Temp\CON") because it needs to be opened with either generic read or generic write access.

CreatFile also commonly fails here with either ERROR_SHARING_VIOLATION (from a paging file) or ERROR_ACCESS_DENIED. But I think those are best handled by the caller, with a PermissionError exception handler. Currently pathlib's resolve method doesn't handle PermissionError like I think it should in non-strict mode. It only handles FileNotFoundError
History
Date User Action Args
2018-03-08 22:29:58izbyshevsetrecipients: + izbyshev, paul.moore, tim.golden, zach.ware, eryksun, steve.dower, miss-islington
2018-03-08 22:29:58izbyshevsetmessageid: <1520548198.4.0.467229070634.issue33016@psf.upfronthosting.co.za>
2018-03-08 22:29:58izbyshevlinkissue33016 messages
2018-03-08 22:29:58izbyshevcreate