[issue25639] open 'PhysicalDriveN' on windows fails (since python 3.5) with OSError: [WinError 1] Incorrect function

STINNER Victor report at bugs.python.org
Tue Nov 17 05:47:45 EST 2015


STINNER Victor added the comment:

I don't know the physical disk type on Windows. Can you read and write from such "file" type? If no, I don't think that it makes sense to support it in io.FileIO. What do you think?

It looks like the file must be opened with specific options, otherwise it doesn't work. See this question on CreateFile():
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/fa2175fe-02f4-4adb-9cb9-5df3d1122cf6/readfile-works-when-handle-opened-with-drive-letterphysical-drive-symlink-but-not-with-device-path


io.FileIO() calls _Py_fstat() for two reasons:

1) raise an error if the path/file descriptor is a directory
2) get the block size

_Py_fstat() is implemented with two Windows calls: GetFileType() & GetFileInformationByHandle().

To solve this issue, we need to have a function telling that the path/file descriptor is a physical disk. In this case, we can skip both checks.

Documentation on Physical Drivers in CreateFile():
https://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx#physical_disks_and_volumes

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25639>
_______________________________________


More information about the Python-bugs-list mailing list