Eryk Sun <eryk...@gmail.com> added the comment:

In case you missed it, I implemented _Py_CreateFile2() in bpo-46506 and rewrote 
os.stat() based on it. Check it out in case you're interested in moving forward 
with a PR in bpo-46506.

For this issue, follow_symlinks is fairly simple to support with 
_Py_CreateFile2(). We may as well add fd support, since that's trivial to add. 
For example:

    if (path->fd != -1) {
        hFile = _Py_get_osfhandle(path->fd);
    } else {
        Py_BEGIN_ALLOW_THREADS
        hFile = _Py_CreateFile2(path->wide, FILE_WRITE_ATTRIBUTES, 0,
                    OPEN_EXISTING, NULL, follow_symlinks, NULL);
        Py_END_ALLOW_THREADS
    }
    if (hFile == INVALID_HANDLE_VALUE) {
        if (path->fd == -1) {
            path_error(path);
        }
        return NULL;
    }

One also has to define the following macros to declare follow_symlinks and fd 
support: UTIME_HAVE_NOFOLLOW_SYMLINKS and PATH_UTIME_HAVE_FD.

To announce support in os.supports_follow_symlinks and os.supports_fd, it 
should be conditioned on MS_WINDOWS, i.e. _add("MS_WINDOWS", "utime"). The os 
module is frozen, so changing these two sets requires rebuilding Python.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46490>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to