]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73991: Add `pathlib.Path.copy_into()` and `move_into()` (#123314)
authorBarney Gale <barney.gale@gmail.com>
Mon, 26 Aug 2024 13:14:23 +0000 (14:14 +0100)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2024 13:14:23 +0000 (14:14 +0100)
commitc68a93c582cc733c399a1cf9e850e5071f79aec1
tree7cf68402c646cd8c5341af70eaf4f5ce9672cbdc
parentdbc1752d4107532d312c78263212e807a3674eb1
GH-73991: Add `pathlib.Path.copy_into()` and `move_into()` (#123314)

These two methods accept an *existing* directory path, onto which we join
the source path's base name to form the final target path.

A possible alternative implementation is to check for directories in
`copy()` and `move()` and adjust the target path, which is done in several
`shutil` functions. This behaviour is helpful in a shell context, but
less so in a stored program that explicitly specifies destinations. For
example, a user that calls `Path('foo.py').copy('bar.py')` might not
imagine that `bar.py/foo.py` would be created, but under the alternative
implementation this will happen if `bar.py` is an existing directory.
Doc/library/pathlib.rst
Doc/whatsnew/3.14.rst
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pathlib/test_pathlib_abc.py
Misc/NEWS.d/next/Library/2024-08-25-16-59-20.gh-issue-73991.1w8u3K.rst [new file with mode: 0644]