GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-73991: Rework `pathlib.Path.copytree()` into `copy()` by barneygale · Pull Request #122369 · python/cpython

Conversation

@barneygale

@barneygale barneygale commented Jul 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.)

  • Issue: Support moving across filesystems in pathlib.Path, as shutil.move() does #73991

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nineteendo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@barneygale
pythonGH-73991: Rework pathlib.Path.copytree() into copy().
b7ce838
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 added the topic-pathlib label Jul 27, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Jul 27, 2024
Support moving across filesystems in pathlib.Path, as shutil.move() does #73991
Closed
barneygale added 8 commits July 28, 2024 00:58
@barneygale
Simplify handling of symlinks
76cf893
@barneygale
Inline _copy_metadata()
b10a3b5
@barneygale
Further symlink tweaks
a67f5a7
@barneygale
Fix copying metadata to non-symlinks
017dd86
@barneygale
Specify target_is_directory when symlinking.
fcc8af1
@barneygale
Tiny simplification.
57efe1f
@barneygale
Skip unnecessary is_dir() when copying symlinks on POSIX.
8bef16b
@barneygale
Docs tweaks
a51ce63
@barneygale
barneygale marked this pull request as ready for review July 30, 2024 17:21
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 30, 2024
@barneygale

barneygale commented Jul 30, 2024

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale barneygale mentioned this pull request Jul 31, 2024
GH-73991: Add pathlib.Path.move() #122073
Merged
barneygale added 2 commits August 4, 2024 14:48
@barneygale
Fix CopyFile2 check
51b1e6d
@barneygale
Merge branch 'main' into merge-copy-copytree
429c7b6
@barneygale

barneygale commented Aug 4, 2024

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale
Docs tweak
023b3a4
nineteendo
nineteendo reviewed Aug 4, 2024
View reviewed changes
Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/pathlib/_abc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@barneygale
Address review feedback
4d6d2dc
@barneygale
barneygale requested a review from nineteendo August 4, 2024 15:53
nineteendo
nineteendo reviewed Aug 4, 2024
View reviewed changes
Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

barneygale added 2 commits August 6, 2024 18:42
@barneygale
Merge branch 'main' into merge-copy-copytree
7801edf
@barneygale
Merge branch 'main' into merge-copy-copytree
5ce229b
@barneygale barneygale mentioned this pull request Aug 7, 2024
GH-73991: Rework pathlib.Path.rmtree() into delete() #122368
Merged
@barneygale
Return the target as a Path object.
5a94525
AA-Turner
AA-Turner reviewed Aug 7, 2024
View reviewed changes
Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/pathlib/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/pathlib/_abc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/pathlib/_abc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/pathlib/_abc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

barneygale and others added 2 commits August 7, 2024 16:11
@barneygale @AA-Turner
Apply suggestions from code review
3b6405b
Co-authored-by: Adam Turner <[email protected]>
@barneygale
Address some review feedback
03f9b7f
barneygale added 2 commits August 7, 2024 16:49
@barneygale
Simplify tracebacks
02e9237
@barneygale
Use absolute imports
fed93fc
@barneygale
barneygale requested a review from AA-Turner August 11, 2024 19:10
AA-Turner
AA-Turner approved these changes Aug 11, 2024
View reviewed changes

@AA-Turner AA-Turner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Danke!

A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Aug 11, 2024
@barneygale

barneygale commented Aug 11, 2024

Copy link
Copy Markdown
Contributor Author

Thank you for the review, very helpful!

AA-Turner reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale
barneygale merged commit a6644d4 into python:main Aug 11, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 11, 2024
blhsing pushed a commit to blhsing/cpython that referenced this pull request Aug 22, 2024
@barneygale @AA-Turner @blhsing
pythonGH-73991: Rework pathlib.Path.copytree() into copy() (pytho…
cde45a6
…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 <[email protected]>
@opk12 opk12 mentioned this pull request Oct 4, 2024
Documenting that the new (3.14) pathlib copy functionality uses Copy-on-Write #124985
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner approved these changes
+1 more reviewer
@nineteendo nineteendo nineteendo left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-pathlib

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@barneygale @AA-Turner @nineteendo
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.