]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73991: Add follow_symlinks argument to `pathlib.Path.copy()` (#120519)
authorBarney Gale <barney.gale@gmail.com>
Wed, 19 Jun 2024 00:59:54 +0000 (01:59 +0100)
committerGitHub <noreply@github.com>
Wed, 19 Jun 2024 00:59:54 +0000 (00:59 +0000)
commit20d5b84f57a6f7e5a76109e483abe39d9f703d56
treedb0e439b59968cd5fcff982e13f1b155ed3f0a80
parent9f741e55c16376412c1473aa45b94314c00a0c43
GH-73991: Add follow_symlinks argument to `pathlib.Path.copy()` (#120519)

Add support for not following symlinks in `pathlib.Path.copy()`.

On Windows we add the `COPY_FILE_COPY_SYMLINK` flag is following symlinks is disabled. If the source is symlink to a directory, this call will fail with `ERROR_ACCESS_DENIED`. In this case we add `COPY_FILE_DIRECTORY` to the flags and retry. This can fail on old Windowses, which we note in the docs.

No news as `copy()` was only just added.
Doc/library/pathlib.rst
Lib/pathlib/_abc.py
Lib/pathlib/_local.py
Lib/pathlib/_os.py
Lib/test/test_pathlib/test_pathlib_abc.py
Modules/_winapi.c