Skip to content

GH-73991: Rework pathlib.Path.copytree() into copy() - #122369

Merged
barneygale merged 20 commits into
python:mainfrom
barneygale:merge-copy-copytree
Aug 11, 2024
Merged

GH-73991: Rework pathlib.Path.copytree() into copy()#122369
barneygale merged 20 commits into
python:mainfrom
barneygale:merge-copy-copytree

Conversation

@barneygale

@barneygalebarneygale commented Jul 27, 2024

Copy link
Copy Markdown
Contributor

Rename pathlib.Path.copy() to _copy_file() (i.e. make it private.)

Rename pathlib.Path.copytree() to copy(), and add support for copying non-directories. This simplifies the interface for users, and nicely complements the upcoming move() and delete() methods (which will also accept any type of file.)


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

Rename `pathlib.Path.copy()` to `_copy_file()` (i.e. make it private.)
Rename `pathlib.Path.copytree()` to `copy()`, and add support for copying
non-directories. This simplifies the interface for users, and nicely
complements the upcoming `move()` and `delete()` methods (which will also
accept any type of file.)
@barneygale
barneygale marked this pull request as ready for review July 30, 2024 17:21
@barneygale

Copy link
Copy Markdown
ContributorAuthor

Making the old copy() method private was a bit of a can of worms, as it made our usage of _winapi.CopyFile2 simpler, which in turn removed any need for UnsupportedOperation to be defined in _os.py rather than _abc.py.

@barneygale

Copy link
Copy Markdown
ContributorAuthor

Hey @nineteendo, could you review this please, if you're up for it? Thanks in advance!

Comment threadDoc/library/pathlib.rst Outdated
Comment threadLib/pathlib/_abc.py
Comment threadDoc/library/pathlib.rst Outdated
Comment threadDoc/library/pathlib.rst Outdated
Comment threadDoc/library/pathlib.rst Outdated
Comment threadDoc/library/pathlib.rst Outdated
Comment threadDoc/library/pathlib.rst Outdated
Comment threadLib/pathlib/__init__.py Outdated
Comment threadLib/pathlib/_abc.py
Comment threadLib/pathlib/_abc.py Outdated
Comment threadLib/pathlib/_abc.py
barneygaleand others added 2 commits August 7, 2024 16:11
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

@AA-TurnerAA-Turner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Danke!

A

@barneygale

Copy link
Copy Markdown
ContributorAuthor

Thank you for the review, very helpful!

@barneygale
barneygale merged commit a6644d4 into python:mainAug 11, 2024
blhsing pushed a commit to blhsing/cpython that referenced this pull request Aug 22, 2024
…n#122369)
Rename `pathlib.Path.copy()` to `_copy_file()` (i.e. make it private.)
Rename `pathlib.Path.copytree()` to `copy()`, and add support for copying
non-directories. This simplifies the interface for users, and nicely
complements the upcoming `move()` and `delete()` methods (which will also
accept any type of file.)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Sign up for freeto 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.

3 participants

@barneygale@AA-Turner@nineteendo