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 eryksun
Recipients eryksun, izbyshev, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2021-01-21.22:23:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611267815.59.0.65251593932.issue42606@roundup.psfhosted.org>
In-reply-to
Content
> can a new handle have non-default access rights? Or can the 
> default change at this point of Windows history?

I don't know what you mean by default access rights.

C open() requests generic access rights, which map to the standard and file-specific rights in the File type's generic mapping. If all of the requested access rights aren't granted, then the open fails with an access denied error. For example, if FILE_WRITE_DATA isn't granted, then open() can't open for appending. A direct CreateFileW() call can remove FILE_WRITE_DATA from the desired access.

DuplicateHandle() can always request the same or less access than the source handle. For some object types, it can perform an access check to get more access, but not for a File handle.

> Currently, the only way to achieve atomic append in Python on 
> Windows that I know is to use a custom opener that would call
> CreateFile() with the right arguments via ctypes/pywin32/etc.

An opener could also work like your PR via os.open(), msvcrt.get_osfhandle(), _winapi.GetFileType(), _winapi.DuplicateHandle(), os.close(), and msvcrt.open_osfhandle().
History
Date User Action Args
2021-01-21 22:23:35eryksunsetrecipients: + eryksun, paul.moore, vstinner, tim.golden, zach.ware, steve.dower, izbyshev
2021-01-21 22:23:35eryksunsetmessageid: <1611267815.59.0.65251593932.issue42606@roundup.psfhosted.org>
2021-01-21 22:23:35eryksunlinkissue42606 messages
2021-01-21 22:23:35eryksuncreate