[Python-Dev] Python 2.5.1
"Martin v. Löwis"
martin at v.loewis.de
Tue May 1 10:13:54 CEST 2007
Alexey Borzenkov schrieb:
> On 5/1/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>> > After doing some research I found that it seems to be impossible to
>> > use CreateFile for a file that doesn't have SHARE_READ.
>> So what about GetFileAttributesEx? What are the conditions under which
>> I can successfully invoke it?
>
> Seems to have the same problems as with CreateFile(...):
That code only tests it for pagefile.sys. My question was about open
handles in general. Both Calvin Spealman and I found that you cannot
reproduce the problem when you, in Python 2.5.0, open a file, and then
try to os.stat() it - even though, in Python 2.5.0, os.stat() will
perform GetFileAttributesEx. So even though we opened the file with
not passing any sharing flags, we could still do GetFileAttributesEx
on it.
I now studied the CRT sources, and it seems that if you use a regular
open() call, the CRT will pass FILE_SHARE_READ | FILE_SHARE_WRITE to
CreateFile. You would have to use _sopen in the CRT to create any
kind of sharing conflict, and that isn't exposed in Python.
So I guess we need continue using pagefile.sys as a test case.
Regards,
Martin
More information about the Python-Dev
mailing list