Eryk Sun <eryk...@gmail.com> added the comment:
> 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(). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42606> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com