GH-73991: Prune `pathlib.Path.copy()` and `copy_into()` arguments by barneygale · Pull Request #123337 · python/cpython · GitHub
Skip to content

GH-73991: Prune pathlib.Path.copy() and copy_into() arguments - #123337

Merged
barneygale merged 1 commit into
python:mainfrom
barneygale:gh-73991-copy-simplify
Aug 26, 2024
Merged

GH-73991: Prune pathlib.Path.copy() and copy_into() arguments#123337
barneygale merged 1 commit into
python:mainfrom
barneygale:gh-73991-copy-simplify

Conversation

@barneygale

@barneygale barneygale commented Aug 26, 2024

Copy link
Copy Markdown
Contributor

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, these arguments may be challenging to implement in future user subclasses of PathBase, which might utilise a native recursive copying method.

No news because copy() and copy_into() are unreleased.


📚 Documentation preview 📚: https://cpython-previews--123337.org.readthedocs.build/

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.
@pfmoore

pfmoore commented Aug 26, 2024

Copy link
Copy Markdown
Member

@barneygale

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants