]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73991: Prune `pathlib.Path.copy()` and `copy_into()` arguments (#123337)
authorBarney Gale <barney.gale@gmail.com>
Mon, 26 Aug 2024 16:05:34 +0000 (17:05 +0100)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2024 16:05:34 +0000 (17:05 +0100)
commit7bd6ebf696efcd5cf8e4e7946f9d8d8aee05664c
tree32e8e1088b2018438394b8a6409b95887f572b60
parent033d537cd4b8c12f2441f1c23960c2153122140a
GH-73991: Prune `pathlib.Path.copy()` and `copy_into()` arguments (#123337)

Remove *ignore* and *on_error* arguments from `pathlib.Path.copy[_into]()`,
because these arguments are under-designed. Specifically:

- *ignore* is appropriated from `shutil.copytree()`, but it's not clear
  how it should apply when the user copies a non-directory. We've changed
  the callback signature from the `shutil` version, but I'm not confident
  the new signature is as good as it can be.
- *on_error* is a generalisation of `shutil.copytree()`'s error handling,
  which is to accumulate exceptions and raise a single `shutil.Error` at
  the end. It's not obvious which solution is better.

Additionally, this arguments may be challenging to implement in future user
subclasses of `PathBase`, which might utilise a native recursive copying
method.
Doc/library/pathlib.rst
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib_abc.py